This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Dynamic Dropdowns Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dynamic Dropdowns" Watch "Dynamic Dropdowns" New topic

Dynamic Dropdowns

Sahil Sharma
Ranch Hand

Joined: Aug 27, 2003
Posts: 152
Is it possible to display dropdowns dynamically thru struts.
Number of dropdowns to be displayed on my JSP is decided at runtime. Sometimes 3 are displayed ans sometimes 4 depending upon the data stored in the DB for the particular user.

sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi sahil

Ofcourse u can do that . By using some logic:iterate and then having the code for the drop down inside

Hope u got what i am saying
Sahil Sharma
Ranch Hand

Joined: Aug 27, 2003
Posts: 152
ya iam using the same. But, I was wondering what should i proivde in the property attribute of html:select. As the dropdown is synamically made.

can u give me some examples, please
Vicky Mohan
Ranch Hand

Joined: Oct 14, 2004
Posts: 130
Suppose if you have the collection named requestColl in the request , you can use the following code to populate the drop down.

<html:select property="selectBox" >
<html options collection="requestColl" property="id" labelProperty="name"/>

selectBox is the name of the drop down box. When the form is submitted, the selected id will be populated in this form variable.

hope this helps.
Sahil Sharma
Ranch Hand

Joined: Aug 27, 2003
Posts: 152
i hv done it. By using logic:iterate and html ptionsCollection combination.
thnx to all for the help.
I agree. Here's the link:
subject: Dynamic Dropdowns
Similar Threads
update html:options
Display a textbox after dropdown change
checkbox & dropdown display in IE
How to hide the option in dropdown,which has been selected in the previous drop down
Getting values in Select from db