Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1843
  • Last Modified:

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>                          



0
sanrich
Asked:
sanrich
1 Solution
 
krishna kishore mellacheruvu venkataCommented:
<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.
0
 
ManishLeadCommented:
You need to compare strRequiredValue with array value.
if(strRequiredValue.equals(stringFromArray)){
--selected as shown above
else
no selected.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now