The MenuCool Color Picker extends all desired <input> fields in HTML form with a color picker.
Features
- Quick & easy to install
- Pure Javascript (3KB only)
- Support reload in AJAX apps
- Appearance customizable
- Provides event handler when a color is selected
- Supported by all major browsers (including IE 6)
Callback event handler
By default, selecting a color by the color picker will automatically update the value of the related input field. If you want additional tasks to be performed after selecting a color from the color picker, you can use the OnColorChanged event handler.
This handler function has two passed in parameters: the selected color, and the index of the chosen color picker.
The following is the implementation of the OnColorChanged handler for the demo:
<script type="text/javascript">
function OnColorChanged(selectedColor, colorPickerIndex) {
var divA = document.getElementById("divA");
var divB = document.getElementById("divB");
if (colorPickerIndex==0)
divA.style.color = selectedColor;
else if (colorPickerIndex==1)
divB.style.color = selectedColor;
}
</script>
You don't need to implement the event handler if you have no additional tasks when the color is changed.