Get a Quote Today!   |   + 1 (301) 424 3903




 
  Community
 
Need Help?
Visit our Training page
Request a Quote or Consultation
SIGN UP FOR THE TERATECH NEWSLETTER
 

ColdCuts

Cut: Clean Alternating row colors
Cut#: 332 
Cut Date: 08/10/2005 
Cutter: Tony 
Topic: Appearance 
Overview: This is a really simple way to alternate row colors.. And you could use it easily to do more than two colors.

Example one is the basic grey/white alternation.

Example two is a grey/white/light red alternation.

 

Cut Code:
#1
<cfset arrColors = ListToArray("##EFEFEF,##FFFFFF")>
<table>
<cfoutput query="my_query">
<tr><td bgcolor="#arrColors[(currentrow mod 2)+1]#">Row #currentrow#.</td></tr>
</cfoutput>
</table>

#2
<cfset arrColors = ListToArray("##EFEFEF,##FFFFFF,##FFCCCC")>
<table>
<cfoutput query="my_query">
<tr><td bgcolor="#arrColors[(currentrow mod 3)+1]#">Row #currentrow#.</td></tr>
</cfoutput>
</table>