DHTMLX Docs & Samples Explorer

### Checked State

Source

    <link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxform_dhx_skyblue.css">

        <script src="../../codebase/dhtmlxcommon.js"></script>
        <script src="../../codebase/dhtmlxform.js"></script>

        <table cellspacing="0" cellpadding="0" border="0">
        <tr><td align="left" valign="top">
            <div id="listObj" style="position: relative; width: 250px;"></div>
        </td><td align="left" valign="top">
            <div id="taData" style="width: 600px; height: 500px; border: #cecece 1px solid; font-family: Tahoma; font-size: 11px; overflow: auto;"></div>
            <input type="button" value="Clear Log" onclick="writeLog('',true);">
        </td></tr>
        </table>
        <script>var dhxList,
    taData,
    j = 0;
    function doOnLoad() {
        taData = document.getElementById("taData");
        dhxList = new dhtmlXForm("listObj");
        dhxList.attachEvent("onBeforeChange", function(name, value, state) {
            // select
            if (dhxList.getItemType(name) == "select") {
                var toReturn = (name != "mediatype");
                writeLog("<b>onBeforeChange</b> event fired. Item name: " + name + ", old value: " + value + ", new value: " + state + ". Returning " + (toReturn ? "<b>true</b>": "<b>false</b>") + ".");
                return toReturn;
            }
            // input
            if (dhxList.getItemType(name) == "input") {
                var toReturn = (name != "moreinfo");
                writeLog("<b>onBeforeChange</b> event fired. Item name: " + name + ", old value: " + value + ", new value: " + state + ". Returning " + (toReturn ? "<b>true</b>": "<b>false</b>") + ".");
                return toReturn;
            }
            // checkbox/radio
            var toReturn = !(String(name).search("return_false") === 0);
            writeLog("<b>onBeforeChange</b> event fired. Item name: " + name + ", value: " + value + ", checked: " + (state ? "yes": "no") + ". Returning " + (toReturn ? "<b>true</b>": "<b>false</b>") + ".");
            return toReturn;
        });
        dhxList.attachEvent("onChange", function(name, value, state) {
            // select
            if (dhxList.getItemType(name) == "select") {
                writeLog("<b>onChange</b> event fired. Item name: " + name + ", new value: " + value);
                return;
            }
            // input
            if (dhxList.getItemType(name) == "input") {
                writeLog("<b>onChange</b> event fired. Item name: " + name + ", new value: " + value);
                return;
            }
            // checkbox/radio
            writeLog("<b>onChange</b> event fired. Item name: " + name + ", value: " + value + ", checked: " + (state ? "yes": "no") + ".");
        });
        dhxList.loadStruct("../common/dhxform3.xml?etc=" + new Date().getTime());
    }
    function writeLog(logText, clearLog) {
        if (clearLog === true) {
            taData.innerHTML = "";
            j = 0;
        } else {
            taData.innerHTML = (++j) + ". " + logText + "<br>" + taData.innerHTML;
        }
    }</script>