Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Help needed with dropdown boxes
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Help needed with dropdown boxes

 Post Reply Post Reply
Author
LeoV View Drop Down
Newbie
Newbie


Joined: 18 March 2003
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote LeoV Quote  Post ReplyReply Direct Link To This Post Topic: Help needed with dropdown boxes
    Posted: 28 April 2003 at 6:23am
I copied the following code for the dropdown boxes to search a database but i do get an error message. The error is:
Error:
Compilatiefout Microsoft VBScript (0x800A0400)
Instructie wordt verwacht
/Search/multidropdown2.asp, line 14
Type = request.form("Type")

The code i have is the following (multidropdown.asp):
<%
P_toep1=request.form("P_toep1")
'since the form submits to itself we need to check to see if a value was selected from the first form.
If P_toep1 = "" Then
'if not then populate the first form with values from the database.

Dim MyConn, RS, connStr

Set MyConn=Server.CreateObject("ADODB.Connection")
connStr="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/Database/VerfWereld_producten.mdb")

'select only DISTINCT values from the database avoiding duplicates.
SQL = "Select DISTINCT P_toep1 From tblPverf"
MyConn.Open connStr
Set RS = MyConn.Execute(SQL)
%>

<form method="Post">
<!--populate the dropdown with values from the P_toep1 field.-->
<Select name = "P_toep1">
<option selected>--Selecteer Ondergrond--

<% While Not RS.EOF %>
<option value="<%=RS("P_toep1")%>">
<%=RS.Fields("P_toep1")%>

<%
RS.MoveNext
Wend

RS.Close
MyConn.Close
Set RS = Nothing
Set MyConn = Nothing
%>

<!--complete the form.-->
</select>
<input type="submit" name="btnSearch" value="Zoeken">
</form>

<%
'now if the first form was submitted then build the second form.
Else

'here we just show the user which value was selected from the first form.
response.write "Uw selectie was: <b>" & P_toep1 & "</b><br>"
response.write "Selecteer nu het type product:"
Set MyConn=Server.CreateObject("ADODB.Connection")
connStr="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/Database/VerfWereld_producten.mdb")

'the second form is populated with the values in the City field of the database.
SQL = "Select Distinct Type From tblPverf Where P_toep1 = '"&P_toep1&"'"
MyConn.Open connStr
Set RS = MyConn.Execute(SQL)
%>

<!--multidropdown2.asp page is the page which displays the results of the query.-->
<form action="multidropdown2.asp" method="Post">
<input type="hidden" name="P_toep1" size="20" value="<%=P_toep1%>">
<Select name = "Type">
<option selected>--Selecteer Type product--

<% While Not RS.EOF %>
<option value="<%=RS("Type")%>">
<%=RS.Fields("Type")%>

<%
RS.MoveNext
Wend

RS.Close
MyConn.Close
Set RS = Nothing
Set MyConn = Nothing
%>

</select>
<input type="submit" name="btnSearch" value="Zoeken">
</form>

<%End If%>

and multidropdown2.asp:

<%
'grab the values selected from both dropdowns.
Type = request.form("Type")
P_toep1 = request.form("P_toep1")

Set MyConn=Server.CreateObject("ADODB.Connection")
connStr="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/Database/VerfWereld_producten.mdb")

'Select the records that match the values from the dropdowns.
SQL = "Select * From tblPverf Where P_toep1 = "
SQL = SQL & "'"&P_toep1&"' And Type = '"&Type&"'"

MyConn.Open connStr
Set RS = MyConn.Execute(SQL)

'here we use the GetRows() method to populate an array with the records that were fetched.
MyArray=RS.GetRows()

'clean up.
RS.Close
MyConn.Close
Set RS = Nothing
Set MyConn = Nothing

'now create an html table.
response.write "<table>"

'now loop through the array and display the records.
For i=0 to UBound(MyArray,2)

response.write "<tr><td>ID = " & MyArray(0,i) & "</td></tr>"

response.write "<tr><td>First Name = " & MyArray(1,i) & "</td></tr>"

response.write "<tr><td>Last Name = " & MyArray(2,i) & "</td></tr>"

response.write "<tr><td>City = " & MyArray(3,i) & "</td></tr>"

response.write "<tr><td>Service = " & MyArray(4,i) & "</td></tr>"

response.write "<tr><td>Active = " & MyArray(5,i) & "</td></tr>"

response.write "<tr><td> </td></tr>"
Next

response.write "</table>"
%>

I know its a long story,
But can anybody help??

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.