Link to home
Start Free TrialLog in
Avatar of Hanybalo
Hanybalo

asked on

populating a list box dynamically

Hi

I want to populate a list box dynamically with data stored in a Vector inside a Bean, is this possible?

what I am doing is using a java class to call the database store the data I need from the database table into a vector.
I can populate a table using forEach tag, so is it possible to populate a list box. if so how would I go about it?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Karaa
Karaa

<%String surg;%>
/// surg is dynamic value of popop
///////each popop has a label and value
<select name="surgeon">
<option value="<%=val%>" <%=((val.toString().equals(surg))?"SELECTED":"")%>><%=label%></option>
            </select>
            
hi guys, I have used something like this

<TR>
   <TD vAlign=top width="10%">
    <P>Select Event you want to set:<BR>
     <SPAN id=event>
      <SELECT style="WIDTH: 20em" size=1 name=event>
<%

Vector v = (Vector) myDBHandler.getAvailabilityFromDB();
Test.EventTypes event;
String eventName;
for( int x =0; x < v.size(); x++)
{
 event = (EventTypes) v.elementAt(x);
 eventName = event.getEventName();
%>
<OPTION value="<%=eventName%>"><%=eventName%></OPTION>
<%}%>
      </SELECT>
     </SPAN></P>
   </TD>
</TR>  

however when ever the user refreshes the page, the items in the list box get added again, is there a way of disabling the refresh button in explorer, and also the address bar, note that my application is only intended to work with explorer.
Hanybalo, if you want to use a vector then that is how you do it, but the problem is as I mentioned above, I am not going for points as the solution is very similar to the other comments.
havalchy...
Can you explain what exaclty u want to be done. I am pretty dumb :)
Avatar of Hanybalo

ASKER

Thanks guys I have done it the same way you told me to do it,

Havalchy
I can see what you mean, when ever a user refreshes the page, the call to the database updates the list, and dublicates occur.