Select attribute :
<select id="colorType">
<option value="text">Text color</option>
<option value="bg">Background color</option>
<option value="border">Border color</option>
</select>
<div id="testInput" style="border:2px black solid;width:300px;height:420px;";>...</div>
<div id="CPcont"></div>
<script>
var z=new dhtmlXColorPicker("CPcont",false,true);
z.setCustomColors("#ff00ff,#00aabb,#6633ff");
z.setOnSelectHandler(setColor);
z.hideOnSelect(false);
function setColor(color) {
var ct = document.getElementById("colorType");
var inp = document.getElementById("testInput");
switch (ct.value) {
case "text":
inp.style.color = '#'+color;
break;
case "bg":
inp.style.backgroundColor = '#'+color;
break;
case "border":
inp.style.borderColor = '#'+color;
break;
}
}
</script>