File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "need help with dropdown box" Watch "need help with dropdown box" New topic

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

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


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
I agree. Here's the link:
subject: need help with dropdown box
It's not a secret anymore!