This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Html:options with Java script" Watch "Html:options with Java script" New topic

Html:options with Java script

Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 117

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

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,

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!!!
subject: Html:options with Java script
Similar Threads
This is my tragedy! need your help
Benny Hinn
Its Oil !!!
Can I access java class using Ajax
SQL help