File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Html:options with Java script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Html:options with Java script" Watch "Html:options with Java script" New topic
Author

Html:options with Java script

Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 123
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

Joined: Jul 19, 2005
Posts: 99
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 ]

We're doomed!!<br />Yay!!!<br />No that's bad Girr!!<br />Yay!!!
 
Don't get me started about those stupid light bulbs.
 
subject: Html:options with Java script