RandomColor()
Last updated May 13, 2003
Version: 2 | Requires: ColdFusion 5 | Library: UtilityLib
Description:
Simply place RandomColor() anywhere you want a truly random HTML color. Fun for the whole family!
Return Values:
Returns a string.
Example:
<table border=1 cellspacing=0>
<tr>
<cfloop from=1 to=10 index="z">
<td bgcolor="#RandomColor()#"> </td>
</cfloop>
</tr>
<tr>
<cfloop from=1 to=10 index="z">
<td bgcolor="#RandomColor()#"> </td>
</cfloop>
</tr>
</table>
</cfoutput>
Parameters:
No arguments.
Full UDF Source:
<cfscript>
/**
* Returns a completely random color. Beautiful, isn't it?
* Version 2 by Raymond Camden
*
* @return Returns a string.
* @author Nathan Strutz (nathans@dnsfirm.com)
* @version 2, May 13, 2003
*/
function randomColor() {
var redColor = formatBaseN(randRange(0,255),16);
var greenColor = formatBaseN(randRange(0,255),16);
var blueColor = formatBaseN(randRange(0,255),16);
if(len(redColor) is 1) redColor = "0" & redColor;
if(len(greenColor) is 1) greenColor = "0" & greenColor;
if(len(blueColor) is 1) blueColor = "0" & blueColor;
return "##" & redColor & greenColor & blueColor;
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
3 day(s) ago
Will Belden added
longTime
9 day(s) ago
James Sleeman added
quickSort
19 day(s) ago
Ben Forta added
GetHostAddress
22 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)