aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes pre-select in option Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "pre-select in option" Watch "pre-select in option" New topic
Author

pre-select in option

thomas wilson
Greenhorn

Joined: Sep 21, 2004
Posts: 24
How can one highlight the last pre-selection in a dynamic list? Thank you


<%
for( int i = 0 ; i < arraylist.size() ; i++ ) {
%>
<option value="<%= arraylist.get( i ).toString() %>"><%= arraylist.get( i ).toString() %></option>
<%
}
%>
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
add selected to the option tag

Eric
Vicky Mohan
Ranch Hand

Joined: Oct 14, 2004
Posts: 130
<%
for( int i = 0 ; i < arraylist.size() ; i++ ) {
%>

<option value="<%= arraylist.get( i ).toString() %>"
<% // add the condition to check if this entry is the selected one%>
SELECTED = "SELECTED"
>
<%= arraylist.get( i ).toString() %>
</option>

<%
}
%>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: pre-select in option
 
Similar Threads
A simple date question
related to best practice
Setting a preselected value in a combo
javax.mail problem with "cc" option.
How to set Default selection in h:selectOneMenu