ODBiC Discussion Board

RE: eachrow alternate color, sam, 05-15-2005

You can use $if(mod($row$,2),color1,color2)

by Roger Harris, May 16, 2005 08:32

The predefined variable $row$ is set to the current row number in the eachrow loop. The expression "mod($row$,2)" will return 0 for even-numbered rows and 1 for odd-numbered rows. So, you can use that as a test in an $if(...) function to set one of two alternate colors. For example, if you're setting the color directly in a <TR> tag, you can do this to alternate the row backgrounds between white and gray:

<TR BGCOLOR="$if(mod($row$,2),#ffffff,#f0f0f0)">
And of course you could do the same thing for the font color.

If you're using CSS style sheets, you can just define two different styles, then use an $if(...) in the <TR> tag to specify a style name for each row.


Post Your Reply:

E-mail  optional

HTTP Link: 
Link text: 

Copyright 1997-2003, Roger Harris. All rights reserved.