Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q3002 What is the easiest way to alternate table row colors when outputting query results?

You are here: irt.org | FAQ | ColdFusion | Q3002 [ previous next ]

As an example, the following code alternates between white and a light gray. If (CurrentRow MOD 2) is 0 (i.e. the row number is an even number), it uses the first color value, otherwise (odd number) it uses the second color value.

<table>
   <cfoutput query="myQuery">
      <tr bgcolor="###Iif(((CurrentRow MOD 2) is 0),de('cccccc'),de('ffffff'))#">
        <td>#Field1#</td>
        <td>#Field2#</td>
      </tr>
   </cfoutput>
</table>

Feedback on 'Q3002 What is the easiest way to alternate table row colors when outputting query results?'

©2018 Martin Webb