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];
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson