ASP Hosting sale!
Double disk space and transfer for FREE!
Limited time offer! Act Now!

aspdev | articles | tutorials | forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to alternate the row colors in HTML table?

 
Post new topic   Reply to topic    ASPdev.org Forum Index -> ASP programming
View previous topic :: View next topic  
Author Message
jon



Joined: 01 Oct 2004
Posts: 40

PostPosted: Wed Nov 03, 2004 10:44 am    Post subject: How to alternate the row colors in HTML table? Reply with quote

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
View user's profile Send private message
administrator
Site Admin


Joined: 01 Oct 2004
Posts: 183

PostPosted: Wed Nov 03, 2004 5:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ASPdev.org Forum Index -> ASP programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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

SQL Tutorial