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??
|