Solved

How to display the value in drop down list in JSP

Posted on 2008-10-04
3
1,819 Views
Last Modified: 2010-02-10
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
Comment
Question by:sanrich
3 Comments
 
LVL 10
ID: 22643252
<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
 
LVL 11

Accepted Solution

by:
Manish earned 500 total points
ID: 25355645
You need to compare strRequiredValue with array value.
if(strRequiredValue.equals(stringFromArray)){
--selected as shown above
else
no selected.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to calculate height of a text using jquery 3 42
How to escape unsafe HTML tags 4 36
How Close unsubmited attempts 10 44
Jquery 7 32
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question