• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pre-select in option

 
thomas wilson
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add selected to the option tag

Eric
 
Vicky Mohan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%
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>

<%
}
%>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic