GeeCON Prague 2014*
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


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Query in Struts" Watch "Query in Struts" New topic
Author

Query in Struts

Vinoo Varghese
Greenhorn

Joined: Dec 22, 2002
Posts: 2
Hi,
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
Sheriff

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
Vinoo,
You may want to re-read the display name policy because your new display name does not comply either.
Jason Menard
Sheriff

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Query in Struts