Hi,
How to get the id of the input that call the color picker ?
I init the color picker like that :
var myCP;
myCP = dhtmlXColorPicker([“header_bgcolor”,“page_bgcolor”]);
myCP.attachEvent(“onChange”, setColor);
So, in the setColor function how to know which input has called the color picker ?
function setColor(color,node)
{
// How to get the id of the input that call the color picker ?
}
However, colorpicker does not have a method that sets a color dynamically for a certain input. Please explain the issue in details. Possibly we could provide some workaround for it.
Hi,
I have resolved the problem like that :
var myCP;
myCP = dhtmlXColorPicker([“header_bgcolor”,“page_bgcolor”,“footer_bgcolor”,“font_color1”]);
myCP.attachEvent(“onChange”, function(color){
switch(myCP.activeNode.node.id)
{
case “header_bgcolor”:
$(’#header_bgcolor’).css(‘backgroundColor’, color);
$(’#header’).css(‘backgroundColor’, color);
break;
case “page_bgcolor”:
$(’#page_bgcolor’).css(‘backgroundColor’, color);
$(’.columns-container’).css(‘backgroundColor’, color);
break;
case “footer_bgcolor”:
$(’#footer_bgcolor’).css(‘backgroundColor’, color);
$(’.footer-container’).css(‘backgroundColor’, color);
break;
case “font_color1”:
$(‘h1,h2,h3,h4,h5,.product-name’).css(‘color’, color);
$(’#font_color1’).css(‘backgroundColor’, color);
break;
}
});