This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Query in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Query in Struts" Watch "Query in Struts" New topic

Query in Struts

Vinoo Varghese

Joined: Dec 22, 2002
Posts: 2
I would like to post the following query.
I am a beginner of Struts.
I use <html:select> and populate it with values from an arraylist.Now my question is :
on selecting a value(an option) from the combo,I want a second combo to be populated on the basis of what was selected in the first.
Maybe,I will make it more clearer below:
For eg:
Suppose I have an array list of states of the US in the first combo.In the second combo,on selecting a state,lets say Washington,I want to populate the second combo with counties of Washington only.
Can anyone send me some code?
Advance Thanks ....
Have a nice day.

Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
Syscom DL,
We don't have many rules at Javaranch, but our display name policy is one of them. Please read this policy and change your display name to comply with it if you wish to continue posting. Thanks.
You can change your display name here.

Matthew Phillips
Jason Menard

Joined: Nov 09, 2000
Posts: 6450
If you are wanting the population to take place without a trip to the server, what you are talking about is a JavaScript problem. Doing things like this normally requires multiple javascript arrays. When the first pulldown is selected, JavaScript dynamically populates the second pulldown. In a case like this you may not want to keep an array containing all the states, and fifty more arrays for all the counties in each state. But if you do want to do that, the helpful people in the HTML/JavaScript forum live and breathe to solve these very sorts of problems.
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
You may want to re-read the display name policy because your new display name does not comply either.
Jason Menard

Joined: Nov 09, 2000
Posts: 6450
Based on what you PM'd me, you would have to submit the form and populate another collection for the second dropdown based on the selection in the first dropdown. Some JavaScript can be done to have the form submitted when the state is selected.
I agree. Here's the link:
subject: Query in Struts
Similar Threads
How to populate second combo box on the basis of first combo
combo box action
How do I populate dynamic combox items
breaking user's hand and heart too....
displaying values in same jsp after user selects value in combo box