Checkbox Howto
</> Source
<!DOCTYPE html>
<html>
<head>
<title>Checkbox Howto</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
<script src="../../../codebase/dhtmlx.js"></script>
<script>
var myForm, formData;
function doOnLoad() {
formData = [
{type: "settings", position: "label-right"},
{type: "checkbox", name: "t1", label: "Checkbox t1 with value «green»", value: "green"},
{type: "checkbox", name: "t2", label: "Checkbox t2 without default value"},
{type: "checkbox", name: "t3", label: "Checkbox t3 with value «green» checked", value: "green", checked: true},
{type: "checkbox", name: "t4", label: "Checkbox t4 without default value checked", checked: true},
{type: "checkbox", name: "t5", label: "Checkbox t5 with value «red» checked", value: "red", checked: true}
];
myForm = new dhtmlXForm("myForm", formData);
}
function setFormData(value) {
myForm.setFormData({
t1: value,
t2: value,
t3: value,
t4: value,
t5: value
});
}
function getFormData() {
var t = myForm.getFormData();
var p = "";
for (var a in t) p += a+": "+String(t[a])+"\n";
document.getElementById("res").value = p;
}
</script>
</head>
<body onload="doOnLoad();">
<div id="myForm"></div>
<div style="clear: both; padding-top: 50px; padding-bottom: 20px;">
<input type="button" value="setFormData(true)" onclick="setFormData(true);">
<input type="button" value="setFormData('true')" onclick="setFormData('true');">
<input type="button" value="setFormData(1)" onclick="setFormData(1);">
<input type="button" value="setFormData('1')" onclick="setFormData('1');">
<br><br>
<input type="button" value="setFormData(false)" onclick="setFormData(false);">
<input type="button" value="setFormData('false')" onclick="setFormData('false');">
<input type="button" value="setFormData(0)" onclick="setFormData(0);">
<input type="button" value="setFormData('0')" onclick="setFormData('0');">
<br><br>
<input type="button" value="setFormData('')" onclick="setFormData('');">
<input type="button" value="setFormData('green')" onclick="setFormData('green');">
<input type="button" value="setFormData('red')" onclick="setFormData('red');">
</div>
<div style="clear: both; padding-top: 20px; border-top: 1px solid #cecece;">
<input type="button" value="getFormData()" onclick="getFormData();">
<br><br>
<textarea id="res" cols="50" rows="5"></textarea>
</div>
</body>
</html>
Documentation
Check documentation to learn how to use the components and easily implement them in your applications.