Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple color output in rows

Status
Not open for further replies.

lothadio

Programmer
Apr 5, 2001
27
SI
I want to alternate the color of rows in a table that I am building that will output query results, how do I do this
row #
1 [red]
2 [white]
3 [red]
4 [white]
5 [red]
6 [white]
7 [red]
8 [white]


Thanks
 
Hey lothadio,

Inside your output loop, just keep track of a variable and set the row color depending on whether it's 1 or 0 like this.

<cfset rowColor = 0>
<cfoutput query=&quot;q1&quot;>
...... Html here ........
<tr bgcolor=&quot;##<cfif rowColor is 0>ffffff<cfelse>000000</cfif>> ..... </tr>
......... More html ........

<cfif rowColor is 0>
<cfset rowColor = 1>
<cfelse>
<cfset rowColor = 0>
</cfif>
</cfoutput>

Hope this helps,
GJ
 
<TR bgcolor=&quot;#iif(queryname.currentrow MOD 2, DE('lightgrey'), DE('white'))#&quot;>

This one is easy to use!
 
Hi!

If you are using query, you may try this also.

<TABLE>
<CFOUTPUT query=&quot;Query1&quot;>
<tr bgcolor=&quot;###Iif(((CurrentRow MOD 2) is 0),DE('cccccc'),DE('ffffff'))#&quot;>
<TD>#Field name1#</TD>
<TD>#Field name2#</TD>
</tr>
</CFOUTPUT>
</TABLE>

All the Best!!

micjohnson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top