recordset in table - make every second row a different colour

Hi,

Using the following code, how do I make every second row have a bgcolor #cccccc. Is it detecting an odd/even count number or is there and easier way.

<table>
<tr>
rs sql, cn
while not rs.eof
<td><%= rs("field") %></td>
rs.movenext
wend
</tr>
</table>

Thanks,

t
mrduckersAsked:
Who is Participating?
 
Dirar Abu KteishCommented:
a small correction on acperkins code, on every two rows not columns, so here is the code that do that:

response.write "<table>"
rs sql, cn
Dim Row
Row = 1
while not rs.eof
     If Row Mod 2 = 0 Then
          response.write "<tr style=""background-color:#cccccc;"">"
     Else
          response.write "<tr>"
     End
     response.write "<td>" & rs("field")  & "</td>"
     rs.movenext
     Row = Row + 1
     response.write "</tr>"
wend
response.write "</table>"
0
 
Anthony PerkinsCommented:
<table>
<tr>
rs sql, cn
Dim Row
Row = 1
while not rs.eof
     If Row Mod 2 = 0 Then  'Add bgcolor #cccccc attribute here
              <td><%= rs("field") %></td>
     Else
              <td><%= rs("field") %></td>
     End
    rs.movenext
    Row = Row + 1
wend
</tr>
</table>
0
 
Anthony PerkinsCommented:
>>a small correction on acperkins code, on every two rows not columns<<
A big correction.  That will teach me not to just copy and paste. Thanks.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Dirar Abu KteishCommented:
welcome ;)
0
 
mrduckersAuthor Commented:
what points split do you guys want?
0
 
Anthony PerkinsCommented:
50-50 is fine with me.
0
 
mrduckersAuthor Commented:
increase to 300
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.