[dhtmlXColorPickerライブラリ] カラーピッカーで選択された色をテキストフィールドの左上に表示する

説明

dhtmlXColorPickerライブラリでカラーピッカーで選択された色をテキストフィールドの左上に表示するにはinputタグの属性としてcolorbox="true"を指定します。

サンプルプログラム

【HTML】
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="ja">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="css/dhtmlxcolorpicker.css" type="text/css" media="all">
<link rel="stylesheet" href="css/main.css" type="text/css" media="all">
<script type="text/javascript" src="js/dhtmlxcommon.js"></script>
<script type="text/javascript" src="js/dhtmlxcolorpicker.js"></script>
<script type="text/javascript" src="js/sample.js"></script>
</head>
<body>
<h1>カラーピッカー</h1>
<form>
<input type="text" id="myCol" name="myCol" colorbox="true">
</form>
</body>
</html>


【sample.js】
window.onload = function(){
var colorP = dhtmlXColorPickerInput("myCol");
colorP.setImagePath("imgs/");
colorP.init();
}
サンプルを実行
[戻る]