Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to color code my dynamic table rows...

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
US
[tt]
Can you guys help me on how to color code my rows in my code below? Thanks


**********************************************************
<tr>
<td class=&quot;myclass&quot; width=&quot;30%&quot;><a href=&quot; <td class=&quot;myclass&quot; width=&quot;20%&quot;><%=(rsPending.Fields.Item(&quot;request_date&quot;).Value)%></td>
<td class=&quot;myclass&quot; width=&quot;30%&quot;><%=Replace(rsPending.Fields.Item(&quot;Request_description&quot;).Value,chr(13),&quot;<br>&quot;)%></td>
<td class=&quot;myclass&quot; width=&quot;10%&quot;>
<div align=&quot;center&quot;><img src=&quot;Images/thumbs_down.gif&quot; width=&quot;15&quot; height=&quot;15&quot;></div>
</td>
</tr>
**********************************************************
[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

banana.gif
rockband.gif
banana.gif
 
Hey TonyU,

Try this (this is assuming that you are already looping this section of code):


<%
i = i + 1
if i = 1 then
color = &quot;#CCCCCC&quot;
else
color = &quot;#666666&quot;
i = 0
end if
%>

<tr bgcolor=&quot;<%=color%>&quot;>
<td class=&quot;myclass&quot; width=&quot;30%&quot;><a href=&quot; <td class=&quot;myclass&quot; width=&quot;20%&quot;><%=(rsPending.Fields.Item(&quot;request_date&quot;).Value)%></td>
<td class=&quot;myclass&quot; width=&quot;30%&quot;><%=Replace(rsPending.Fields.Item(&quot;Request_description&quot;).Value,chr(13),&quot;<br>&quot;)%></td>
<td class=&quot;myclass&quot; width=&quot;10%&quot;>
<div align=&quot;center&quot;><img src=&quot;Images/thumbs_down.gif&quot; width=&quot;15&quot; height=&quot;15&quot;></div>
</td>
</tr>

Hope this helped.

Cheers,

G.
 
[tt]Yes I'm looping thru the table, and where exactly would I place your suggestion on my page?
[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

banana.gif
rockband.gif
banana.gif
 
[tt]Oops, I think I got it. Never mind. I'll post if I don't.
[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

banana.gif
rockband.gif
banana.gif
 
[tt]

Ok, this code is coloring all my rows #CCCCCC and not #666666

<%
i = i + 1
if i = 1 then
color = &quot;#CCCCCC&quot;
else
color = &quot;#666666&quot;
i = 0
end if
%>

<tr bgcolor=&quot;<%=color%>&quot;>

Any clue why?
[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

banana.gif
rockband.gif
banana.gif
 
Do it like this, assuming ur wanting to alternate the color on every line
<%
if i = 1 then
color = &quot;#CCCCCC&quot;
i = 0
else
color = &quot;#666666&quot;
i = 1
end if
%>
 
Or like this:

Code:
Dim color(2)

color(1) = &quot;#CCCCCC&quot;
color(2) = &quot;#666666&quot;

If i=1 then 
  i=2 
   else 
  i=1
End if

<tr bgcolor=&quot;<%=color(i)%>&quot;>
www.vzio.com
ASP WEB DEVELOPMENT



 
Modification to previous post just so I can have turn too :)
Code:
<%
Dim color(1), i
color(0) = &quot;#666666&quot;
color(1) = &quot;#CCCCCC&quot;
%>
...
<tr style=&quot;color:<%=color(i mod 2)%>&quot;>
<%
i = i + 1
%>
-Tarwn &quot;The problem with a kludge is eventually you're going to have to back and do it right.&quot; - Programmers Saying (The Wiz Biz - Rick Cook)
&quot;Your a geek!&quot; - My Girlfriends saying
 
Modification to previous post just so I can have turn too :)
Code:
<%
Dim color(1), i
color(0) = &quot;#666666&quot;
color(1) = &quot;#CCCCCC&quot;
%>
...
<tr style=&quot;color:<%=color(i mod 2)%>&quot;>
<%
i = i + 1
%>
-Tarwn &quot;The problem with a kludge is eventually you're going to have to back and do it right.&quot; - Programmers Saying (The Wiz Biz - Rick Cook)
&quot;Your a geek!&quot; - My Girlfriends saying
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top