DHTMLX Docs & Samples Explorer

Menu Items Visibility Control

Select Item    

Source
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxmenu_dhx_skyblue.css">
<script src="../../codebase/dhtmlxcommon.js"></script>
<script src="../../codebase/dhtmlxmenu.js"></script>
<script src="../../codebase/ext/dhtmlxmenu_ext.js"></script>
 
<div style="height: 250px;"><div id="menuObj"></div></div>
<div>
    <table border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td>Select Item</td>
            <td width="10">&nbsp;</td>
            <td><select id="sel"></select></td>
            <td width="10">&nbsp;</td>
            <td><input type="button" value="Show" onclick="show();"> <input type="button" value="Hide" onclick="hide();"> <input type="button" value="Is Hidden?" onclick="isHidden();"></td>
        </tr>
    </table>
</div>
 
<br>
<script>
var menu;
var sel = document.getElementById("sel");
function initMenu() {
    menu = new dhtmlXMenuObject("menuObj");
    menu.setIconsPath("../common/imgs/");
    menu.loadXML("../common/dhxmenu.xml?e=" + new Date().getTime(), function() {
        menu.forEachItem(function(itemId) {
            if (menu.getItemType(itemId) != "separator")
                sel.options.add(new Option(menu.getItemText(itemId), itemId));
        });
    });
}
function getId() {
    return sel.options[sel.selectedIndex].value;
}
function show() {
    menu.showItem(getId());
}
function hide() {
    menu.hideItem(getId());
}
function isHidden() {
    alert(menu.isItemHidden(getId()));
}
</script>