Dynamic List BoxesHere's a list box generated from the Samples database:
The code to do this is surprisingly simple. First open up your database connection if its not already opened, create your recordset by doing an appropriate query, then do the Do While...Loop to pull data from your recordset and put it into your select options. The Samples database has a Name and ID field that I'm using for this particular example. Here's the Do While...Loop code:
<%
Do while not rs.eof
ID=rs("ID")
UserName=rs("name")
response.write "<option value=""" & ID & """>" & UserName & "</option>"
rs.movenext
loop
%>
And that's all there is to it!
|