473,574 Members | 3,153 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populate a second drop down based on a selection from another above it

14 New Member
Based off a selection from an above drop-down on the same page?
Sep 10 '07 #1
16 2360
r035198x
13,262 MVP
Based off a selection from an above drop-down on the same page?
Yes it's possible.
Are you talking about a Java application or an web application with HTML and Javascript?
Sep 10 '07 #2
JosAH
11,448 Recognized Expert MVP
Based off a selection from an above drop-down on the same page?
Sure, why not? Instantiate a new PopupMenu and populate it with whatever you
want and display the thing. What's the problem? Or are you talking Javascript?

kind regards,

Jos
Sep 10 '07 #3
JosAH
11,448 Recognized Expert MVP
r035198x is catching up: he beat me by that >.< much ;-)

kind regards,

Jos
Sep 10 '07 #4
mimsc
14 New Member
Yes it's possible.
Are you talking about a Java application or an web application with HTML and Javascript?
It's a web app with some html, unfortunately I'm new to javascript and I hear thats the way to go with this problem.

here's what I got:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <%
  3. Vector theStates = WeatherDAO.getWeatherStates();
  4. %>
  5.  
  6. label for="weatherStat">State:</label>
  7.  
  8. <select name="weatherStat" id="States">
  9. <% for (int i=0; i< theStates.size(); i++) {  %>
  10.  
  11. <OPTION VALUE=<%=theStates%>> <%=theStates.elementAt(i)%> </OPTION>
  12.  
  13. <% 
  14. }
  15. %>
  16. </select>        
  17.  
  18. <label for="weatherCity">City:</label>
  19.     <select name="weatherCity" id="Cities">
  20.  
  21.  
  22. <%
  23. Vector theCities = WeatherDAO.getWeatherCities(WeatherStat);
  24. %>    
  25.  
  26. <% for (int i=0; i< theCities.size(); i++) {  %>
  27.  
  28. <OPTION VALUE=<%=theCities%>> <%=theCities.elementAt(i)%> </OPTION>
  29.  
  30. <% 
  31. }
  32. %>
  33.  
  34.  
  35. </TD></TR>
  36. </center>
  37. <TR><TD> 
  38. <br>
  39. <br>
  40. <center>
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. </select></TD></TR>
  48. </TABLE>
  49.  
nothing populates in the second drop-down
Sep 10 '07 #5
r035198x
13,262 MVP
It's a web app with some html, unfortunately I'm new to javascript and I hear thats the way to go with this problem.

here's what I got:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <%
  3. Vector theStates = WeatherDAO.getWeatherStates();
  4. %>
  5.  
  6. label for="weatherStat">State:</label>
  7.  
  8. <select name="weatherStat" id="States">
  9. <% for (int i=0; i< theStates.size(); i++) {  %>
  10.  
  11. <OPTION VALUE=<%=theStates%>> <%=theStates.elementAt(i)%> </OPTION>
  12.  
  13. <% 
  14. }
  15. %>
  16. </select>        
  17.  
  18. <label for="weatherCity">City:</label>
  19.     <select name="weatherCity" id="Cities">
  20.  
  21.  
  22. <%
  23. Vector theCities = WeatherDAO.getWeatherCities(WeatherStat);
  24. %>    
  25.  
  26. <% for (int i=0; i< theCities.size(); i++) {  %>
  27.  
  28. <OPTION VALUE=<%=theCities%>> <%=theCities.elementAt(i)%> </OPTION>
  29.  
  30. <% 
  31. }
  32. %>
  33.  
  34.  
  35. </TD></TR>
  36. </center>
  37. <TR><TD> 
  38. <br>
  39. <br>
  40. <center>
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. </select></TD></TR>
  48. </TABLE>
  49.  
nothing populates in the second drop-down
1.) Vector is old. Use ArrayList
2.) If the cities are coming from a database as well then you probably may have to do it using Ajax or else you load all cities and states into arrays and then play around with those arrays. Either way it's a web problem so I'll move this to the Javascript forum.

P.S This problem appears so often that if you do a search on it you'll find a solution in the Javascript forum
Sep 10 '07 #6
mimsc
14 New Member
1.) Vector is old. Use ArrayList
2.) If the cities are coming from a database as well then you probably may have to do it using Ajax or else you load all cities and states into arrays and then play around with those arrays. Either way it's a web problem so I'll move this to the Javascript forum.

P.S This problem appears so often that if you do a search on it you'll find a solution in the Javascript forum

thanx for the input...appreci ate it
Sep 10 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
See if this link helps.
Sep 10 '07 #8
mimsc
14 New Member
See if this link helps.

hey thanx man, Im about to look at it right now!
Sep 10 '07 #9
mimsc
14 New Member
ok so I think I got the javascript syntax down...how can I access the saved parameter inside the script to be used in a query to populate a "city" drop-down menu below

example below:

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Vector theStates = WeatherDAO.getWeatherStates();
  3. %>
  4.  
  5.  
  6. <html>
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  9. <title>Insert title here</title>
  10. <script language="JavaScript" 
  11.    type="text/JavaScript">
  12. function GetCities(testVar)
  13.  {
  14.    var weatherState = document.testForm.weatherStat.selectedIndex;  <<----- I need to use this value to create another drop down menu on this same page
  15.  
  16.  
  17.  }
  18. </script>
  19.  
  20. <body>
  21.  
  22.  
  23.  
  24.  
  25. <TR bgColor="#ffffff"><TD COLSPAN="2">
  26. <TABLE CELLPADDING="3" CELLSPACING="2">
  27. <TR><TD>
  28.  
  29. </FONT></CENTER><BR>
  30. <BR>
  31. <TABLE BORDER="0" CELLSPACING="5" CELLPADDING="5" WIDTH="100%">
  32. <TR BGCOLOR="#C0C0C0" ><TD COLSPAN="2" ALIGN="CENTER"> <FONT SIZE=+3><B> Weather Services</B></FONT>
  33. </TD></TR>
  34. </TABLE>
  35. <HR SIZE="3" NOSHADE>
  36. <font size=+1>Select the State and City for which you would like to receive weather information.</font><br>
  37. <TR><TD> 
  38. <center>
  39.  
  40. <form name="testForm">
  41. <label for="weatherStat">State:</label>
  42.  
  43. <select name="weatherStat" onchange="testVar = this.value"> 
  44.  
  45. <% for (int i=0; i< theStates.size(); i++) {  %>
  46.  
  47. <OPTION VALUE=<%=theStates%>> <%=theStates.elementAt(i)%> </OPTION>
  48.  
  49. <% 
  50. }
  51. %>
  52. </select>
  53.  
  54. <label for="weatherCity">City:</label>
  55.     <select name="weatherCity" id="Cities">
  56.  
  57.  
  58.  


Im lost...any help would be appreciated
Sep 10 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
15404
by: Greg Scharlemann | last post by:
I am attempting to populate a drop down menu based on the selection of a different drop down menu. However, it is not working correctly, I cannot figure out for the life of me what exactly happens because I am not getting any errors on the page. <html> <script language="javascript"> var phaseArray = new phaseArray(4); var phaseTypeId =...
1
6346
by: Greg Scharlemann | last post by:
I would like to automatically populate a drop down menu when the page loads based on the selection of an item in a different drop down menu. I made a test page that when drop down #1 changes, drop down #2 populates. Does anyone know how to get drop down #2 to populate based on what is selected in drop down #1 when the page loads? Here is...
1
1200
by: ckerns | last post by:
I have a drop down that pulls data (ADO) when the page loads. I want to make a selection on this drop down and populate the other controls on the page based on the selection. I want to do this without reloading (submitting) the whole page. How do i do this? tia
3
1656
by: Alonso | last post by:
Hi, I have two drop downs and the content of the second one must changed everytime the user changes the selection in the first one. Is any easy way of doing this? Thanks in advance. Alonso
1
2588
by: rajarameshvarma | last post by:
Hi, I have two user controls in an asp.net webpage each contains a DropDownList. Depending on the selection of the drop down in one user control i need to populate data in the other drop down which is in another usercontrol in the same page. Autopostback property for the first dropsown is set to true. please anybody can help me in this...
1
2218
by: Flanman | last post by:
I have an ASP web form that I want to populate fields based on the first field choice. Example I have 4 fields item, price, delivery, availability. I have all these items setup in an access table. When a user chooses an option from the item drop down, the price, delivery, availability will then populate. I have already made my connection to...
1
1749
by: KMEscherich | last post by:
Using Access '97 Hi there, am wondering if someone can please help me with the following: I have a master table (T_INVESTIGATION) that contains the following fields as well as other fields. T_INVESTIGATION LOC_CODE, STR_ADDR, CITY,
1
4200
by: dcrewhouse | last post by:
Hello-- I have been working with the problem for a while and have yet to find a solution. Does anyone know how to populate a drop down list box based on the selection from another drop-down in a data access page. I know it can be done with combo boxes in forms, but how do I do this in a data access page? Any help would be great! Trent
5
3990
by: giandeo | last post by:
Hello Experts. Could you find a solution for this problem please! I have the following tables in Access Database Table Name: origin Fields Names: country, countrycode Table Name: make Fields Names: countrycode, make
0
7843
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8274
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7863
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6514
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5660
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3776
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1375
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1102
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.