Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Html:options with Java script

 
Luke Zechariah
Ranch Hand
Posts: 128
  • 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
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic