DHTMLX Docs & Samples Explorer

Initialization with attachment to input

You can define colorPicker properties right through INPUT element attributes in HTML:

  • colorbox - adds color box before input
  • customcolors - activate Custom Colors block inside ColorPicker
  • selectonclick - make color selection by clicking in palette, but not while moving over (beter for using on very old computers)


  • Source
    <link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxcolorpicker.css" />
       <style>
    .cs_colorBox {
      float:right;
    }
       </style>
       <script  src="../../codebase/dhtmlxcommon.js"></script>
       <script  src="../../codebase/dhtmlxcolorpicker.js"></script>
       <script>
    function initColorPicker() {
        var myCP1 = new dhtmlXColorPickerInput('dhtmlxColorPicker1');
        myCP1.setImagePath("../../codebase/imgs/");
        myCP1.init();
        var myCP2 = new dhtmlXColorPickerInput('dhtmlxColorPicker2');
        myCP2.setImagePath("../../codebase/imgs/");
        myCP2.init();
        var myCP3 = new dhtmlXColorPickerInput('dhtmlxColorPicker3');
        myCP3.setImagePath("../../codebase/imgs/");
        myCP3.init();
    }
    </script> <div><input type="text" imagepath="../../codebase/imgs/" id="dhtmlxColorPicker1"></div><br> <div><input type="text" imagepath="../../codebase/imgs/" colorbox="true" id="dhtmlxColorPicker2"></div><br> <div><input type="text" imagepath="../../codebase/imgs/" customcolors="true" selectonclick="true" id="dhtmlxColorPicker3"></div>