Link to home
Start Free TrialLog in
Avatar of sanrich
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(inCompneyKey, "", "");
     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>
 &nbsp;&nbsp;
</td>                          



Avatar of krishna kishore mellacheruvu venkata
krishna kishore mellacheruvu venkata
Flag of India image

<select name="ttranrational" tabindex="5" >
<%
 /// Get the data from User table
  ArrayList arlist = umUtil.getSrcTrNeedsist(inCompneyKey, "", "");
     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>
 &nbsp;&nbsp;
</td>                          
try above code.
ASKER CERTIFIED SOLUTION
Avatar of Manish
Manish
Flag of India 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