Did You Know – Most Browsers Have a Built-in Color Picker?
Well, I didn’t (If you said ‘no’ then response.write “either”) !
Here is an example that uses JavaScript to keep a color picker and a text input in sync with each other:
<script>
function sync(s,t) {
var a=document.getElementById(s);
var b=document.getElementById(t);
if (a.value!=b.value) b.value=a.value;
}
</script>
<input id="PickColor" type="COLOR" value="#207cff" onchange="sync('PickColor','HexColor');" />
<input id="HexColor" type="TEXT" value="#207cff" onchange="sync('HexColor','PickColor');" />
|
|
Here is the Color picker without the JavaScript:
<input name="WebColor" type="COLOR" value="#207cff" /> If you add this to a form, when the user submits the form, one of the form fields will be “WebColor”. |