Populating a drop down list
4 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   al_still
Posted On:   Wednesday, March 27, 2002 11:40 AM

Hi, I am having trouble with the following : I have a JSP that edits the values of a selected user (taken from a DB). But I cannot set the initial value of a drop down list like I can with regular text boxes. In a text box I set value to <%= name %> is there an equivilant for a drop down list

Regards, Alan.

Re: Populating a drop down list

Posted By:   Anonymous  
Posted On:   Wednesday, March 27, 2002 12:40 PM

Another suggestion..

For combo boxes with lots of options,I find it's cleaner to generate the HTML on the server side, like this:


String vals = {"one","two","three","four",...};
String txts = {"Number One","numTwo","nbr_three",...};
String usrSelection = rs.getString("Num");
String sHTML = "
";

Re: Populating a drop down list

Posted By:   Arun_Bharathan  
Posted On:   Wednesday, March 27, 2002 12:09 PM

Make sure you have SELECTED attribute to the OPTION element for which you want as a default(initial) value.

Re: Populating a drop down list

Posted By:   Dan_Waldner  
Posted On:   Wednesday, March 27, 2002 12:06 PM

I've run into this problem as well. This is how I solved it:

For the drop down box, there's a property ( I believe its SELECTED) that you can insert in the OPTION tag in order to make that the default. Just do a statement similar to this one:


<%

String value;

//Go get value for drop box here

%>