Or taking the same technique one step farther, use the mod value directly in
the class names:

<STYLE>
.row0 { background-color: silver; }
.row1 { background-color: gray; }
</STYLE>
<CFOUTPUT>
<TABLE>
<CFLOOP QUERY="foo">
<TR CLASS="row#(CurrentRow MOD 2)#"><TD>#CurrentRow#</TD></TR>
</CFLOOP>
</TABLE>
</CFOUTPUT>

-----Original Message-----
From: Rick Osborne [Mojo] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 21, 2001 3:03 PM
To: CF-Talk
Subject: RE: Alternating BG colors on a <TD>


Chad Gray asked:
> When using a <CFOUTPUT QUERY=""> tag on a table how do i get every other
> <TD> to have a background color?


My favorite way:

<STYLE>
.evenrow { background-color: silver; }
.oddrow { background-color: gray; }
</STYLE>
<CFSET EvenOdd=ListToArray("oddrow,evenrow")>
<CFOUTPUT>
<TABLE>
<CFLOOP QUERY="foo">
<TR CLASS="#EvenOdd[IncrementValue(CurrentRow MOD
2)]#"><TD>#CurrentRow#</TD></TR>
</CFLOOP>
</TABLE>
</CFOUTPUT>

This allows me to define any styles I want in the STYLE part, including
background color, fonts, etc.  But then, I'm a CSS nut ...  Plus I like
using the MOD function and arrays.  Takes me back to my C days when
programming was so much more fun.  ;)

-R
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to