DHTMLX Docs & Samples Explorer

Events

Combo provides four events:
- onChange - event called when combo value changed,
- onKeyPressed - event called when key pressed inside combo: has keyCode as the parameter,
- onSelectionChange - event called when preselected value inside combo change,
- onBlur - event called when focus moved out from combo.
Event handlers can be set using attachEvent method

Source
<script>
window.dhx_globalImgPath = "../../codebase/imgs/";
</script> <link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxcombo.css"> <script src="../../codebase/dhtmlxcommon.js"></script> <script src="../../codebase/dhtmlxcombo.js"></script> <table> <tr> <td> <div id="combo_zone2" style="width:250px; height:30px;"></div> </td> </tr> <tr> <td> <div id="logarea" style="background-color:lightgrey;height:218px;width:250px; overflow:auto"></div> </td> </tr> </table> <script>
var combo = new dhtmlXCombo("combo_zone2", "alfa2", 250);
combo.loadXML("../common/data.xml");
function doLog(str) {
    var log = document.getElementById("logarea");
    log.innerHTML = log.innerHTML + str + "<br/>";
    log.scrollTop = log.scrollHeight;
}
combo.attachEvent("onChange", onChangeFunc);
combo.attachEvent("onKeyPressed", onKeyPressedFunc);
combo.attachEvent("onSelectionChange", onSelectionChangeFunc);
combo.attachEvent("onBlur", onBlurFunc);
function onChangeFunc() {
    doLog("" + 'onChange' + " event has occured");
    return true;
}
function onKeyPressedFunc(key) {
    doLog("Key " + key + " was pressed");
    return true;
}
function onSelectionChangeFunc() {
    doLog("Selection was changed");
    return true;
}
function onBlurFunc() {
    doLog("" + 'onBlur' + " event has occured");
    return true;
}
</script>