There are many solutions to alternating the background color. Generally, you take a variable and just swap it from one color to another.
I recently saw a solution posted on ASPMessageBoard.com that took an array of colors to rotate through and used that. It was simple, yet elagent:
Dim Cnt
Dim BGColors
BGColors = Array("white", "gray", "blue")
Cnt = -1
While Not Recordset.EOF
Cnt = Cnt + 1
Response.Write "<tr bgcolor='" & BGColors(Cnt MOD (UBound(BGColors) + 1)) & "'>"
Response.Write "<td>" & Recordset(1) & "</td>"
Response.Write "</tr>"
Recordset.MoveNext
Wend
To add change the number of colors. You only need to change the line:
BGColors = Array("white", "gray", "blue")
|