Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | ColdFusion | Q3002 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.