• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

dropdown selection in Struts2

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Refer this example http://javachamp.blogspot.com/2008/06/struts-2-ajax-drop-down-example.html
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

}
 
reply
    Bookmark Topic Watch Topic
  • New Topic