Multiple Dynamic Form Select
One advantage huge advantage about this script is that you will only run a query when you need to run a query and only write to the screen when you need to, thus saving on bandwidth and time. With this script there is also no waiting for the page to refresh or reload while getting your next list of options.
In our example below, you will need to create two files. The first one will be the page that your form is on, for the sake of our example we will name it "TheForm.asp". The second file will be named "GetOptions.asp".
Here is the ASP code for TheForm.asp:
Here is the ASP code for GetOptions.asp:
<select name="SecondField"> <% Set objrs = Server.CreateObject ("ADODB.RecordSet") SqlStr = "SELECT SecondField " & _ "FROM TheTable " & _ "GROUP BY SecondField " & _ "ORDER BY SecondField ASC " objrs.Open SqlStr, ConnectionStr, adOpenStatic, adLockOptimistic,adCmdText While Not Objrs.EOF Response.Write "<option value=" & chr(34) & Objrs("SecondField") & chr(34) & ">" & _ objrs("SecondField") & _ "</option>" Objrs.MoveNext Wend objrs.Close Set objrs = Nothing %> </select>