View previous topic :: View next topic |
Author |
Message |
jon
Joined: 01 Oct 2004 Posts: 40
|
Posted: Wed Nov 03, 2004 10:44 am Post subject: How to alternate the row colors in HTML table? |
|
|
I'm displaying data from my Access database table into an HTML table in my ASP page and I want to make the row colors to alternate (odd rows white and the even rows gray). Can you help me with that?
Yours,
Jon |
|
Back to top |
|
|
administrator Site Admin
Joined: 01 Oct 2004 Posts: 183
|
Posted: Wed Nov 03, 2004 5:11 pm Post subject: |
|
|
Hi Jon,
For each row displayed within your loop, check if the number of the row is odd or even and display different row color depending on that:
Code: |
iCount = 0
While Not objRs.EOF
If iCount Mod 2 = 0 Then
sColor = "#DDDDDD"
Else
sColor = "#EEEEEE"
End If
Response.Write "<tr bgcolor=""" & sColor & """><td>" & objRs("Value1") & "</td></tr>"
objRs.MoveNext
iCount = iCount + 1
Wend
|
Cheers, _________________ Peter
ASP & ASP.NET Articles and Tutorials |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|