Jump to content

Two or more Jscolor pickers on one Page.


cjenkins08

Recommended Posts

I am using the jscolor picker for the user to select color of text. I need multiple color pickers on one page.

 

I am using these functions, because the HEX needs to be converted to RGB for output.

 

Javascript:

<script type="text/javascript">
function updateInfo(color) {
    document.getElementById('info-r').value = color.rgb[0];
    document.getElementById('info-g').value = color.rgb[1];
    document.getElementById('info-b').value = color.rgb[2];
}

</script>


<script type="text/javascript">
function updateInfo(top-color) {
    document.getElementById('top-info-r').value = color.rgb[0];
    document.getElementById('top-info-g').value = color.rgb[1];
    document.getElementById('top-info-b').value = color.rgb[2];
}
</script>
<script type="text/javascript" src="jscolor/jscolor.js"></script>

HTML

<input name="color" class="color{onImmediateChange:'updateInfo(this);'}" value="000000" size="9">
<input type="hidden" id="info-r" name="colorr"/>
<input type="hidden" id="info-g" name="colorg"/>
<input type="hidden" id="info-b" name="colorb"/>


<input name="top-color" class="color{onImmediateChange:'updateInfo(this);'}" value="000000" size="9">
<input type="hidden" id="top-info-r" name="topcolorr"/>
<input type="hidden" id="top-info-g" name="topcolorg"/>
<input type="hidden" id="top-info-b" name="topcolorb"/>

The first color picker is working Name = "color", this is the code pulled directly from jscolor's site.

Any ideas why the second one is not pulling the RGB colors?

 

Thanks

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.