sanrich
asked on
How to display the value in drop down list in JSP
I want to high light the selected value in drop down, How can I do that.... For example
String strRequiredValue = "display this value";
Now from DB in my arralist I am getting three Values
1- "display this value1"
2- "display this value"
3- ""display this value2";
In JSP I need to highlight - strRequiredValue = "display this value";
How can we do this, I have following code to get the arraylist and display in drop down, I am able to display the values but dont know how to high light the selected value
Please provide me sample for this.
<select name="ttranrational" tabindex="5" >
<%
/// Get the data from User table
ArrayList arlist = umUtil.getSrcTrNeedsist(in CompneyKey , "", "");
for(int i=0;i<arlist.size();i++){
String strScreenName[] = (String [])arlist.get(i);
String strValue = strScreenName[1] ; //+ ";"+ strScreenName[3];
%>
<option value="<%= strValue %>" > <%= strValue %> </option>
<%
}
%>
</select>
</td>
String strRequiredValue = "display this value";
Now from DB in my arralist I am getting three Values
1- "display this value1"
2- "display this value"
3- ""display this value2";
In JSP I need to highlight - strRequiredValue = "display this value";
How can we do this, I have following code to get the arraylist and display in drop down, I am able to display the values but dont know how to high light the selected value
Please provide me sample for this.
<select name="ttranrational" tabindex="5" >
<%
/// Get the data from User table
ArrayList arlist = umUtil.getSrcTrNeedsist(in
for(int i=0;i<arlist.size();i++){
String strScreenName[] = (String [])arlist.get(i);
String strValue = strScreenName[1] ; //+ ";"+ strScreenName[3];
%>
<option value="<%= strValue %>" > <%= strValue %> </option>
<%
}
%>
</select>
</td>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<%
/// Get the data from User table
ArrayList arlist = umUtil.getSrcTrNeedsist(in
for(int i=0;i<arlist.size();i++){
String strScreenName[] = (String [])arlist.get(i);
String strValue = strScreenName[1] ; //+ ";"+ strScreenName[3];
if (i==2)
{
%>
<option value="<%= strValue %>" selected > <%= strValue %> </option>
<%
}
else
{
%>
<option value="<%= strValue %>" > <%= strValue %> </option>
<%
}
%>
</select>
</td>
try above code.