jQuery in Action, 2nd edition*
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "dropdown selection in Struts2" Watch "dropdown selection in Struts2" New topic
Author

dropdown selection in Struts2

Susan John
Greenhorn

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).

Thanks
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

Refer this example http://javachamp.blogspot.com/2008/06/struts-2-ajax-drop-down-example.html


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
Greenhorn

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()">


javascript:

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

}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dropdown selection in Struts2