Print Page | Close Window

Problem with dropdown box

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=9098
Printed Date: 29 March 2026 at 12:33pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Problem with dropdown box
Posted By: stevem2003
Subject: Problem with dropdown box
Date Posted: 21 January 2004 at 7:10am

Hi,

I am at present using the code below to get the dropdown box to populate with data from an access database.
However I would now like to create a second dropdown, but I would like the data displayed to depend on the choice of the first box.
Example: If I choose colours in box one, box two only shows colours.
In my database I have the following data:-

id    system    query
1     internet   admin
2     internet   project
3     intranet   admin
4     intranet   project

Code:

<% Option Explicit %>
<%
Dim adoCon, strCon, rs, strSQL, strID

strID = Request.QueryString("select1")

if strID = "" then

Set strCon = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
strCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &Server.MapPath("db")
strSQL = "SELECT * FROM table ORDER BY system ASC"
rs.Open strSQL,strCon

%>
<html>
<head>
<title>Combo Test</title>
</head>
<body>
<form method="POST" action="next.asp">
<table border=0>
<tr>
<td>System</td>
<td>
<select size="1" id="select1" name="select1">
<%
While NOT rs.EOF
%>
<option value="<%=rs("system")%>"><%=rs("system")%>&l t;/option>
<%
rs.MoveNext
WEND
%>
</select></td>
</tr>
</table>
<input type="submit" value="Submit" name="Go">
</form>
</body>
</html>
<%
rs.Close
strCon.Close
set rs = Nothing
set strCon = Nothing

else

Response.Redirect strID

end if
%>

Any Help, Suggestions, or tutorials would be appreciated.
Steve



-------------
There's no point running if you're on the wrong road!



Replies:
Posted By: aalavar
Date Posted: 21 January 2004 at 10:33am

If you want an easy way to do it, and you don't need both drop down boxes to appear on the same page, then simply use a form and send the result of your first drop down box to a second page.  On the second page, request the querystring, and use that to populate the second drop down box.  If you want them to be on the same page, the coding is a little more difficult, but can still be done.  I'm not entirely sure what you are trying to accomplish, so if you could be more specific, I will try to help.



Posted By: Semikolon
Date Posted: 21 January 2004 at 10:44am

this should be easy with some javascript.. but dont ask me about that.. js is not my strongest side..



Posted By: Bluefrog
Date Posted: 21 January 2004 at 11:13pm

I use javascript to dynamically change drop downs. Have a look at the bottom of the page here:

http://maven3d.com/en/show_the_product.asp?PID=1 - http://maven3d.com/en/show_the_product.asp?PID=1

or go here:

https://maven3d.com/secure/product_zoom.asp?PID=1 - https://maven3d.com/secure/product_zoom.asp?PID=1

Select 1 and continue to the next page.

You have to select a country before you can get shipping rates. Same basic problem.

The HTML is too much to post here. Just have a look at the source.

 



-------------
http://renegademinds.com/" rel="nofollow - Renegade Minds - Guitar Software http://renegademinds.com/Default.aspx?tabid=65" rel="nofollow - Slow Down Music


Posted By: stevem2003
Date Posted: 23 January 2004 at 5:33am
Many Thanks everyone for your help

-------------
There's no point running if you're on the wrong road!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net