Solved

How to display the value in drop down list in JSP

Posted on 2008-10-04
3
1,831 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

623 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