wood burning stoves*
The moose likes Struts and the fly likes need help with dropdown box 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 "need help with dropdown box" Watch "need help with dropdown box" New topic
Author

need help with dropdown box

meera rao
Ranch Hand

Joined: Jun 30, 2005
Posts: 67
I have 2 dropdown boxes. The second box depends on the first one.

The first dropdown box is static and has values to select an option.

The second one is based on the first one and accesses different tables in the database based on the selection.

I am using the Struts html:select tag for the dropdown boxes.

Can somebody give me any hints to code this part?
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

You'll need javascript.

You can either:
1) Store all tables as javascript collections and dynamically swap out the values of the second menu when the first menu changes.
2) Make a call to the server when the first menu changes to have it return the proper values for the second menu.


A good workman is known by his tools.
meera rao
Ranch Hand

Joined: Jun 30, 2005
Posts: 67
Thanks for the reply. Can you explain me how should i proceed with the code?
Ganesh Gowtham
Ranch Hand

Joined: Mar 30, 2005
Posts: 225

hi meera...

as marc said there were some ways which includes ..

1. store all pertaining data in the javascript variables array
2. get data from the data base based on the data from the first the select option...

Event : onFocusOut("callMyMtd(this)") in first select box.
it will be triggered when when the user clicks and tabs oput from that select box there u have to write

Document.formname.action="kkk\ddd\ddd.do";
documnet.forname.submit();

so above code will call ur pertainig data for second option keep in sesstion or req and show in JSp page using the Tag libs.....

is above enough ...

let me know if i am missing something



Thanks, Ganesh Gowtham
http://ganesh.gowtham.googlepages.com
 
Consider Paul's rocket mass heater.
 
subject: need help with dropdown box
 
Similar Threads
how to populate dropdown box dynamically
drop down box using struts
Populate values in drop down
Dropdown box value reset upon partial submit
problem with extracting values from a combo box.....