File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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