CFLib.org – Common Function Library Project

EvenOddColor(num, evencolor, oddcolor)

Last updated November 27, 2001

author

Mark Andrachek

Version: 1 | Requires: CF5 | Library: UtilityLib

Description:
This function takes 3 arguments, num,EvenColor, and OddColor. num is the number you want to return the color for, EvenColor is the color returned if num is even, OddColor is the color returned if num is odd. This can be used to easily alternate table row or even cell colors.

Return Values:
Returns a string.

Example:

<CFOUTPUT>
<TABLE>
<CFLOOP FROM="1" TO="10" INDEX="x">
    <TR>
    <TD BGCOLOR="#EvenOddColor(variables.x,'##FFFFFF','##CECECE')#">#variables.x#
    </TD>
    </TR>
</CFLOOP>
</TABLE>
</CFOUTPUT>

Parameters:

Name Description Required
num The number to check for even/oddness. Yes
evencolor The color to use for even numbers. Yes
oddcolor The color to use for odd numbers. Yes

Full UDF Source:

/**
 * Returns different colors if the number passed to it is even or odd.
 * Modified by RCamden
 * 
 * @param num      The number to check for even/oddness. 
 * @param evencolor      The color to use for even numbers. 
 * @param oddcolor      The color to use for odd numbers. 
 * @return Returns a string. 
 * @author Mark Andrachek (hallow@webmages.com) 
 * @version 1.1, November 27, 2001 
 */
function EvenOddColor(num,evencolor,oddcolor) {
    return Arguments[(num mod 2 )+ 2];
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson