Solved

recordset in table - make every second row a different colour

Posted on 2006-07-23
7
234 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
Comment Utility
<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
Comment Utility
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
Comment Utility
>>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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 6

Expert Comment

by:dxz2
Comment Utility
welcome ;)
0
 

Author Comment

by:mrduckers
Comment Utility
what points split do you guys want?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
50-50 is fine with me.
0
 

Author Comment

by:mrduckers
Comment Utility
increase to 300
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 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

10 Experts available now in Live!

Get 1:1 Help Now