Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query in Struts

 
Vinoo Varghese
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinoo,
You may want to re-read the display name policy because your new display name does not comply either.
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic