Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dropdown selection in Struts2

 
Susan John
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Refer this example http://javachamp.blogspot.com/2008/06/struts-2-ajax-drop-down-example.html
 
seenu java
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

}
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic