EvenOddColor(num, evencolor, oddcolor)
Last updated November 27, 2001
Version: 1 | Requires: ColdFusion 5 | 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:
<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:
<cfscript>
/**
* 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];
}
</cfscript>
Search CFLib.org
Latest Additions
Dave Anderson added
iniToStruct
20 day(s) ago
Dave Anderson added
deDupeArray
20 day(s) ago
Richard added
dice
22 day(s) ago
Isaac Dealey added
getRelative
a while ago
Top Rated
backupDatabase
Rated 5.0, 22 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)
highlightAndCrop
Rated 5.0, 4 time(s)