This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Html:options with Java script

 
Luke Zechariah
Ranch Hand
Posts: 128
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

My jsp page is on struts and I have a set of options let assume the names of the countries. For example the list of options such as

United States
Albania
Algeria
Canada
India
Mexico

Now when I select any one country like "United States" it should display the states of that specific country.

Can any one help me on how to do it. Thank you very much in advance,

Arun.
 
Scheepers de Bruin
Ranch Hand
Posts: 99
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only (non-IE-specific) way I know of doing this, is to reload the page with the selected country as a parameter:

<select name="country" on_click="document.form[0].action='?cntr=' + this.selectedIndex; document.form[0].submit()" >

Then you basically reload the page with cntr as a parameter, set to the index of the selected country. Obviously on_click should be one word with no underscore. If you use a base href tag in the page, you have to include the url of the page before the '?'.

You could use document.location, but then you would lose all the other field values.
[ October 10, 2005: Message edited by: Scheepers de Bruin ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic