This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes dropdown selection in Struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "dropdown selection in Struts2" Watch "dropdown selection in Struts2" New topic

dropdown selection in Struts2

Susan John

Joined: Apr 12, 2011
Posts: 7
Hi All

I have a struts2 based JSP page. In that there are 2 dropdown boxes which has few values and these values have relation.(for example 1st dropdown has value like A , B , C and 2nd dropdown has values like Albert, Bob , Charles).

On selection of B in 1st dropdown the 2nd drop down value should change to Bob. Same way if I select Charles in 2nd dropdown , the first dropdown value should changed to C).

Any idea how I can do in Javascript (And as I mentioned the controls are Struts2 specific).

Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

Refer this example

ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
seenu java

Joined: Oct 03, 2011
Posts: 12
if the values are predefined,it is simple ,you can do with javascript.

<s:select id="dropdown1" onchange = "resetDropdown2()" >

<s:select id="dropdown2" onchange = "resetDropdown1()">


function resetDropdown2{
your logic here
document.getElementById("dropdown2").value=""; // here you can set by the index also

function resetDropdown1{
your logic here
document.getElementById("dropdown1").value=""; // here you can set by the index also

Consider Paul's rocket mass heater.
subject: dropdown selection in Struts2