Jay --

The IIF works like an inline CFIF statement (I'm sure to be flamed for that
gross overgeneralization), so it can only work for two colors (true/false).
If you want to provide more than two colors, you need to grab a color entry
out of an array/list.  As you loop, you increment a loop counter, and grab
the color entry out of the list.  It's basically the same code as you have
before, but different.  Here are two code snippits to show you how it's
done, one via a list, and one via an array.   The LstColors is your
pre-defined list of colors... you can set it as you see fit.  I haven't
tested this code, but I'm pretty sure it will work.

Example, using a list (easy to understand)
=====================
<CFSET lstColors = "FFFFE7,FAFAFA,FF0000">
<CFSET lstColorsLen = listlen(lstColors)>

<CFSET RowNo = 0>
<TABLE BORDER=0>
<CFLOOP FROM=1 TO=1000 INDEX="ID">
        <CFSET rowNo = incrementvalue(rowno mod lstColorsLen)>
        <CFOUTPUT><TR BGCOLOR="#listgetat(lstColors,rowno)#"><TD>
&nbsp;</TD></TR></CFOUTPUT>
</CFLOOP>
</TABLE>

Example, using an array (marginally faster)
===================
<CFSET lstColors = "FFFFE7,FAFAFA,FF0000">
<CFSET ColorArray = listtoarray(lstColors)>
<CFSET ColorArrayLen = arraylen(ColorArray )>

<CFSET RowNo = 0>
<TABLE BORDER=0>
<CFLOOP FROM=1 TO=1000 INDEX="ID">
        <CFSET rowNo = incrementvalue(rowno mod ColorArrayLen)>
        <CFOUTPUT><TR BGCOLOR="#ColorArray[rowno]#"><TD> &nbsp;
</TD></TR></CFOUTPUT>
</CFLOOP>
</TABLE>


Array Sample, using a query instead of a static loop
===================
<CFSET lstColors = "FFFFE7,FAFAFA,FF0000">
<CFSET ColorArray = listtoarray(lstColors)>
<CFSET ColorArrayLen = arraylen(ColorArray )>

<!--- Grab Data for Processing --->
<CFQUERY NAME="GetData" DATASOURCE="CRISN">
SELECT FullName,Title,Insitution,Address1,Address2,City,State,Zip FROM
Contacts WHERE State='CA'
</CFQUERY>

<!--- Loop over the data, and print out each record--->
<CFSET RowNo = 0>
<TABLE BORDER=0>
<CFLOOP QUERY="GetData">
        <CFSET rowNo = incrementvalue(rowno mod ColorArrayLen)>
        <CFOUTPUT><TR
BGCOLOR="#ColorArray[rowno]#"><TD>#FullName#<br>#title#<br>#institution#<br>
#Address#<br>#city#, #state# #zip#</TD></TR></CFOUTPUT>
</CFLOOP>
</TABLE>

---
Daniel Dewey                |"According to the rule of averages, if you
Systems Developer           | stand with one foot in a bucket of ice,
MCP (NT srvr/wkstn/eprise)  | and the other in a bed of hot coals, you
[EMAIL PROTECTED]          | should be feeling fine" -- Unknown
http://www.pobox.com/~dewey |                 610-868-1421, x115
           The National Association of Colleges and Employers

     These opinions are mine, and may not be the same as my employer 

-----Original Message-----
From: Jay Patton [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 17, 2001 3:52 PM
To: CF-Community
Subject: any ideas?


does anyone know how i can make this tag output 3 colors instead of 2?

<tr bgcolor="#IIf(DirList.CurrentRow  Mod 2, DE('FFFFE7'), DE('FAFAFA'))#"> 

thanks,

Jay Patton
Web Pro USA
406.549.3337 ext. 203
1.888.5WEBPRO
www.webpro-usa.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to