• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

drop down box using struts

 
Chris Johnson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 7486
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"pfcbuilder pfcbuilder"

Please edit your profile so that your publicly displayed name complies with the JavaRanch Naming Policy. Thank you for your cooperation.
 
Junilu Lacar
Bartender
Posts: 7486
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic