Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

neater asp code 1

Status
Not open for further replies.

frogggg

Programmer
Jan 17, 2002
182
US
Jorgandr gave me this code a while back, but I didn't use it then, because I thought I'd use dtc listboxes instead of manual asp, but I couldn't get them to work, so I used this after all, and it works just great.
It's a little hard to read with all the <%, and I was wondering if there's a neater way to write the same piece. Here it is and thanks for your help.

<SELECT Name=&quot;CareerLevel&quot; Size=&quot;1&quot;>
<%DO UNTIL rsCareerLevel.eof%>
<OPTION Value=&quot;<%Response.write rsCareerLevel.fields.getValue(&quot;CareerID&quot;)%>&quot;
<%IF rsCareerLevel.fields.getValue(&quot;CareerID&quot;) = rsValidatePassword.fields.getValue(&quot;CareerLevel&quot;) THEN%>
SELECTED
<%end if%>
><%Response.write rsCareerLevel.fields.getValue(&quot;CareerName&quot;)%></OPTION>
<%rsCareerLevel.MoveNext%>
<%loop%>
</SELECT>
 
Code:
<SELECT Name=&quot;CareerLevel&quot; Size=&quot;1&quot;>
<%
DO UNTIL rsCareerLevel.EOF
  Response.Write &quot;<OPTION Value=&quot; & rsCareerLevel(&quot;CareerID&quot;) 

  If rsCareerLevel(&quot;CareerID&quot;) = rsValidatePassword(&quot;CareerLevel&quot;) Then
    Response.Write &quot; SELECTED&quot;
  End If

  Response.write &quot;>&quot; & rsCareerLevel(&quot;CareerName&quot;) & &quot;</OPTION>&quot; & vbcrlf

  rsCareerLevel.MoveNext
Loop
%>
</SELECT>
Tony
 
I would probably try this, so you don't have all the <%%> tags...

Code:
<SELECT Name=&quot;CareerLevel&quot; Size=&quot;1&quot;>
<%
DO UNTIL rsCareerLevel.eof
  Response.write &quot;<OPTION Value='&quot; & rsCareerLevel.fields.getValue(&quot;CareerID&quot;) & &quot;'&quot; 
IF rsCareerLevel.fields.getValue(&quot;CareerID&quot;) = rsValidatePassword.fields.getValue(&quot;CareerLevel&quot;) THEN
  response.write &quot; SELECTED&quot;
end if
response.write &quot;>&quot; & rsCareerLevel.fields.getValue(&quot;CareerName&quot;) & &quot;</OPTION>&quot;
rsCareerLevel.MoveNext
loop
%>
</SELECT>
 
Thanks jlsmithprism, your method worked fine, and it's so much easier to read.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top