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
https://forums.phpfreaks.com/topic/288419-two-or-more-jscolor-pickers-on-one-page/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.