PDA

View Full Version : yahoo Color Picker Help



baleric
12-04-2006, 01:03 AM
1) Script Title: YUI Color Picker

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex11/yuicolorpicker/index.htm

3) Describe problem:

Hey guys,
i am using this color selector and have come across a problem, if you use the color selector it fills a color box next to the text field, i would like it to fill 2 box's on the same page, but after i add another div with the same ID it doesn't load the second one as well, but if i delete the first one the second one starts working, is there a way i can make the 2 color box's work simultaneously?

thanks for any help

baleric
12-04-2006, 10:47 PM
can anyone help?

ddadmin
12-05-2006, 07:49 AM
Well, the line within ddcolorposter.js that actually populates the text field with the color value is this:


this.targetobj.value=this.hexvalue //set field to selected hex color value

Try changing that to:


this.targetobj.value=this.hexvalue //set field to selected hex color value
document.getElementById("anotherfield").value=this.hexvalue

where "anotherfield" is the ID of the other text field box. I haven't tested this out yet, though it should work.

baleric
12-06-2006, 02:18 AM
thanks ddadmin,
but that loads the values into another text field, what i want to do is make a preview of the colors 2 times on the same page... so the colorbox that changes colors to the right hand side of the text field still changes aswell as another colorbox...

so i get 2 previews of the color from the one text fields value.]

hope you understand

ddadmin
12-06-2006, 08:01 AM
Ah. You'll need some more extensive changes then. Replace the original ddcolorposter.js file with the attached instead. This modified one supports changing two color boxes to reflect the currently selected color, instead of the default one. On your page then, instead of calling:


ddcolorposter.fillcolorbox("colorfield1", "colorbox1", "colorbox2") //PREFILL "colorbox1" with hex value from "colorfield1"

You'd call:


ddcolorposter.fillcolorbox("colorfield1", "colorbox1", "colorbox2") //PREFILL "colorbox1" with hex value from "colorfield1"

and instead of the code:


<form>
# <input type="text" id="colorfield1" onFocus="ddcolorposter.echocolor(this, 'colorbox1')"> <span id="colorbox1" class="colorbox">____</span> <br />
</form>

You'd have something like:


<form>
# <input type="text" id="colorfield1" onFocus="ddcolorposter.echocolor(this, 'colorbox1', 'colorbox2')"> <span id="colorbox1" class="colorbox">____</span> <span id="colorbox2" class="colorbox">____</span><br />
</form>

Untested like before, but should work.

baleric
12-06-2006, 11:15 PM
Thank you so much ddadmin, your a life saver :)

rafamachine
04-01-2007, 02:16 PM
Hello!
Can anybody knows how to set the color of the yui color picker ? i mean, send hex value and set the colorpicker gui to show it.
thanks!