Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Problem with dropdown box
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Problem with dropdown box

 Post Reply Post Reply
Author
stevem2003 View Drop Down
Newbie
Newbie
Avatar

Joined: 07 November 2003
Location: United Kingdom
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevem2003 Quote  Post ReplyReply Direct Link To This Post Topic: Problem with dropdown box
    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

Back to Top
aalavar View Drop Down
Groupie
Groupie


Joined: 08 December 2003
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote aalavar Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post 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..

Back to Top
Bluefrog View Drop Down
Senior Member
Senior Member


Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bluefrog Quote  Post ReplyReply Direct Link To This Post 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

or go here:

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.

 

Back to Top
stevem2003 View Drop Down
Newbie
Newbie
Avatar

Joined: 07 November 2003
Location: United Kingdom
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevem2003 Quote  Post ReplyReply Direct Link To This Post Posted: 23 January 2004 at 5:33am
Many Thanks everyone for your 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.