File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes drop down box using struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "drop down box using struts" Watch "drop down box using struts" New topic

drop down box using struts

Chris Johnson

Joined: Dec 07, 2004
Posts: 4
I have two dropdown box when a user select the first dropdown box.
the second dropdown box will be populated with data without affecting other controls in the form.

Example the first dropdown box is populated a list of department, so when theuser selects a department the second combo box will be populated the list of employees belonging to that department that was selected by the user on the first dropdown box without affecting other controls in the form?
Both dropdown box get the data from the database.

Can some one show me how to do this?

Thanks very much.
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6521

"pfcbuilder pfcbuilder"

Please edit your profile so that your publicly displayed name complies with the JavaRanch Naming Policy. Thank you for your cooperation.

Junilu - [How to Ask Questions] [How to Answer Questions]
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6521

There are at least two ways to do this:

1. Call a JavaScript function in the onchange event of the first dropdown. This means that you will have to create JavaScript arrays that will hold all the possible combinations.

2. Submit the form via a JavaScript function call in the onchange event. In the backend, detect what the selected item was in the first drop down and then re-populate the options collection for the second drop down accordingly.
I agree. Here's the link:
subject: drop down box using struts
It's not a secret anymore!