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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternating colors in table

Status
Not open for further replies.

majorbroncosfan

Programmer
Feb 23, 2001
121
US
I currently am trying to run a table in an active server page that will be in alternating colors for the rows. I have declared a recordset and am using the following code:

do while not (prstCurrent.eof)
if pstrColor = "#FFFFFF" then
pstrColor = "#9999FF"
response.write &quot;<tr bgcolor=&quot; & pstrColor & &quot;>&quot;

else
pstrColor=&quot;#FFFFFF&quot;
response.write &quot;<tr bgcolor=&quot; & pstrColor & &quot;>&quot;
end if
...
prstCurrent.MoveNext
...

Is this correct or is there a better way to do this?
 
looks good to me. ;-)
penny.gif
penny.gif
 
Hi,

this is another way, it looks simpler to me and has less if:

do while not rs.EOF
if color = &quot;yellow&quot; then
color = &quot;lightgreen&quot;
else
color = &quot;yellow&quot;
end if
response.write(&quot;<tr bgcolor='&quot; & color & &quot;'><td>&quot; & rs(&quot;field&quot;) & &quot;</td></tr>&quot;)
rs.MoveNext
loop

bye.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top