Solved

recordset in table - make every second row a different colour

Posted on 2006-07-23
7
238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Obtain data from database .mdb 4 30
Button on Table, name table1 not working 4 34
ASP Classic, check if Querystring is UCase or LCase 8 29
window close link 7 35
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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…

733 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