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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ALTERNATE TABLE BACKGROUND 1

Status
Not open for further replies.

kingjjx

Programmer
Sep 18, 2001
181
0
0
US
Hi, I want to change the table background of my query results to alternate colors .. ie black, white, black white

how do i do this ?
thank you
 
Actually it is pretty simple. Are you looking to alternate rows like greenbar paper?

<CFSET ROWCOLOR=&quot;Black&quot;>
<TABLE>
<!---start a loop, query, etc...--->
<TR BGCOLOR=&quot;#ROWCOLOR#&quot;>
<TD>
data
</TD>
</TR>
<CFIF ROWCOLOR EQ &quot;Black&quot;>
<CFSET ROWCOLOR=&quot;White&quot;>
<CFESLE>
<CFSET ROWCOLOR=&quot;Black&quot;>
</CFIF>
<!--- end the loop, query, etc... --->
</TABLE>


Mitch Duszynski
Web Developer
Human Kinetics
PO Box 5076, Champaign, IL 61825
Tel: 217-351-5076 x2474 | Fax: 217-351-2674
mitchd@hkusa.com |
 
Back in 1998 I picked up this method - originally by Rob Bilson and Mike Van Hoozer (I don't have the original site listed, sorry)

<CFQUERY name=&quot;Get Results&quot; datasource=&quot;CNet&quot;>
SELECT * FROM CustomerRecords
</CFQUERY>

<TABLE>
<CFOUTPUT query=&quot;GetResults&quot;>
<CFIF (CurrentRow MOD 2) IS 1>
<!--- a row using first color --->
<TR>
<TD bgcolor=&quot;##FFCC99&quot;>#CustomerName#</TD>
<TD bgcolor=&quot;##FFCC99&quot;>#State#</TD>
</TR>
<CFELSE>
<!--- a row using the second color --->
<TR>
<TD bgcolor=&quot;##EFD6C6&quot;>#CustomerName#</TD>
<TD bgcolor=&quot;##EFD6C6&quot;>#State#</TD>
</TR>
</CFIF>
</CFOUTPUT>
</TABLE>

George K
 


<TR bgcolor=&quot;#iif(GetResults.currentrow MOD 2, DE('black'), DE('white'))#&quot;>
<TD bgcolor=&quot;##FFCC99&quot;>#CustomerName#</TD>
<TD bgcolor=&quot;##FFCC99&quot;>#State#</TD>
</TR>

Rock on!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top