What about a color picker for a cfform?

Following my previous post about the slider, in this example I created a color picker with three sliders, red, green and blue. On the onChange event of these sliders, I'm updating the color of the rectangle to reflect the changes.


Following my previous post about the slider, in this example I created a color picker with three sliders, red, green and blue. On the onChange event of these sliders, I'm updating the color of the rectangle to reflect the changes.

This is the code:

function comp2Hex(val) { return (val<16) ? "0" + val.toString(16) : val.toString(16); } var red = Number(slideRed.text); var green = Number(slideGreen.text); var blue = Number(slideBlue.text); var rgb = red << 16 | green << 8 | blue; var c = Number("0x"+comp2Hex(rgb)); colorDisplay.setStyle("backgroundColor", c);

You can view a live example
Download the source.