This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Populating dropdown box

 
El Roy Cabildo
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 7465
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nope. im from cebu and you? thanks anyway.
 
El Roy Cabildo
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the second dropdown box should be populated by the data from the database.
 
Junilu Lacar
Bartender
Pie
Posts: 7465
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic