Solved

recordset in table - make every second row a different colour

Posted on 2006-07-23
7
235 Views
Last Modified: 2008-03-06
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
0
Comment
Question by:mrduckers
  • 3
  • 2
  • 2
7 Comments
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 150 total points
ID: 17163235
<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
 
LVL 6

Accepted Solution

by:
dxz2 earned 150 total points
ID: 17163546
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17163900
>>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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Expert Comment

by:dxz2
ID: 17164167
welcome ;)
0
 

Author Comment

by:mrduckers
ID: 17164647
what points split do you guys want?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17164655
50-50 is fine with me.
0
 

Author Comment

by:mrduckers
ID: 17164658
increase to 300
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now