View Full Version : Javascript Color Selection Problem.

11-30-2006, 11:44 PM
Hey guys,
i am using the color selector from http://www.dynamicdrive.com/dynamicindex11/yuicolorpicker/index.htm
and have com 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 that box and also another one 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


12-01-2006, 03:01 AM
it doesnt work because the script probably calls to the element by id. and the first elemement it sees with that specific id is the only one it will change. you will haveto add in another line to specify the second div (give it a different id).

12-01-2006, 09:32 AM
id must be unique on the same page/session. Give another id to your second element , and (not an elegant method, but it allows you to avoid modify the code) repeat the called function passing that id as parameter:

onfocus="ddcolorposter.echocolor(this, 'colorbox1');ddcolorposter.echocolor(this, 'colorotherbox1')"

12-02-2006, 07:18 AM
thanks for the help guys,

onfocus="ddcolorposter.echocolor(this, 'colorbox1') ; ddcolorposter.echocolor(this, 'colorotherbox1')"

that wasn't successful, i was really hoping that would work im a bit of a javascript noob,
it only changes the last ddcolorposter command, so wateva colorbox is last thats what changes.
is there any other way to do this without changing the main code?