Solved

How to display the value in drop down list in JSP

Posted on 2008-10-04
3
1,809 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now