Not Faster but less redundancy:
String mSelected
for (int a=1;a<32;a++)
{
if ( a==day )
mSelected = "SELECTED";
} else {
mSelected = "";
}
%>
<OPTION <%= mSelected %> VALUE="<%= a %>"><%= a %></OPTION>
<%
}
%>
Or a bit shorter but harder to read:
<% for (int a=1;a<32;a++) { %>
<OPTION <% if ( a==day ) { %><%= SELECTED %><% } %> VALUE="<%= a
%>"><%= a %></OPTION>
<% } %>
Or even shorter:
<% for (int a=1;a<32;a++) { %>
<OPTION <%= (a==day) ? "SELECTED" : "" %> VALUE="<%= a %>"><%= a
%></OPTION>
<% } %>
Or if you need this in more places:
<%!
String getSelected(boolean aSelected) {
if (aSelected) {
return "SELECTED";
} else {
return "":
}
}
%>
<% for (int a=1;a<32;a++) { %>
<OPTION <%= getSelected(a==day)) %> VALUE="<%= a %>"><%= a
%></OPTION>
<% } %>
> -----Urspr�ngliche Nachricht-----
> Von: David Cassidy [mailto:[EMAIL PROTECTED]]
> Gesendet: Freitag, 22. Februar 2002 17:49
> An: Tomcat Users List
> Betreff: Re: JSP not returning full page problem
<snip/>
> would be easier as ..
>
> for (int a=1;a<32;a++)
> {
> if ( a==day )
> out.write("<OPTION SELECTED VALUE=\"" + a +"\">"
> +a+"</OPTION>\n");
> else
> out.write("<OPTION VALUE=\"" + a +"\">" +a+"</OPTION>\n");
> }
<snip/>
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>