aspose file tools*
The moose likes Struts and the fly likes Populating dropdown box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Populating dropdown box" Watch "Populating dropdown box" New topic
Author

Populating dropdown box

El Roy Cabildo
Greenhorn

Joined: Oct 19, 2002
Posts: 23
I have a problem, 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 the user 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 drop down box without affecting other controls in the form?
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4462
    
    6

This can be done with JavaScript. See this example
BTW, your name is very familiar. You aren't by any chance an Iliganon, are you?
El Roy Cabildo
Greenhorn

Joined: Oct 19, 2002
Posts: 23
nope. im from cebu and you? thanks anyway.
El Roy Cabildo
Greenhorn

Joined: Oct 19, 2002
Posts: 23
the second dropdown box should be populated by the data from the database.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4462
    
    6

If the second dropdown gets data from the db, you'll probably still want to use javascript. Your first drop down would have an onchange event. In the event handler, you'll have to submit the form with document.forms[0].submit() Process the request and populate the bean that will be used to display the options for the second dropdown.
Here's a tutorial that shows how to use the Struts select/options tags.
Iliganon. I studied in USC Talamban for a year though.
 
jQuery in Action, 2nd edition
 
subject: Populating dropdown box