OnChange() Event in Struts

V

Vitthal Bhat

Hi I am new to Struts,

I have 2 list box in Jsp Page.The first contain All country names.
Second list box has to populate values based on counntry selected from
first listbox.(Say second list box has to contain State names). I have
to implement this through struts. so how to implement this.pleas help
 
R

Ryan Stewart

Vitthal Bhat said:
Hi I am new to Struts,

I have 2 list box in Jsp Page.The first contain All country names.
Second list box has to populate values based on counntry selected from
first listbox.(Say second list box has to contain State names). I have
to implement this through struts. so how to implement this.pleas help

To do something when a select box changes, you will have to use JavaScript, not
Struts. As your subject line said, use the onchange attribute to run a script.
Assuming JS is available, you would probably want to use an XMLHttpRequest if
possible. (Google it.) Be sure your application is still usable if JS is turned
off unless you've got it in writing that JS is a requirement.
 
B

Bryce

To do something when a select box changes, you will have to use JavaScript, not
Struts. As your subject line said, use the onchange attribute to run a script.
Assuming JS is available, you would probably want to use an XMLHttpRequest if
possible. (Google it.) Be sure your application is still usable if JS is turned
off unless you've got it in writing that JS is a requirement.

Or look into JSF if you don't want to use javascript (although
XMLHttpRequest is a great way to do it)
 
W

Wendy S

Vitthal Bhat said:
I have 2 list box in Jsp Page.The first contain All country names.
Second list box has to populate values based on counntry selected from
first listbox.(Say second list box has to contain State names). I have
to implement this through struts. so how to implement this.pleas help

If you want Struts to handle it, you'll need to submit the form when the
country changes.

Using JavaScript to do it on the client side can work, except that you'd
have to send all the states for all the countries to the browser, or else
have a way for the JavaScript to make a request behind the scenes. I think
that's possible, but I've never done it.
 
R

Ryan Stewart

Wendy S said:
have a way for the JavaScript to make a request behind the scenes. I think
that's possible, but I've never done it.
Check out XMLHttpRequest on Google.
 
C

cloud9

go 4 DHTML.my friend told me he solved this(postback problem) using
DHTML.I dont know how but as someone said you have to dump all the
countries and it's related states
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top