Using UserData In Menu Items
Select Item | (Click menu item to select) |
|
Current UserData ("data") | ||
UserData Name | ||
UserData Value |
Select Item | (Click menu item to select) |
|
Current UserData ("data") | ||
UserData Name | ||
UserData Value |
<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="2" cellpadding="2"> <tr> <td>Select Item</td> <td width="10"> </td> <td><div id="item">(Click menu item to select)</div></td> </tr> <tr> <td>Current UserData ("data")</td> <td> </td> <td><input id="item_ud" type="text" value="" disabled="true"></td> </tr> <tr> <td>UserData Name</td> <td> </td> <td><select disabled><option>data</option></select></td> </tr> <tr> <td>UserData Value</td> <td> </td> <td><input id="item_new_ud" type="text" value=""> <input type="button" value="Update" onclick="update();"></td> </tr> </table> </div> <br> <script></script>var menu, mid; function initMenu() { menu = new dhtmlXMenuObject("menuObj"); menu.setIconsPath("../common/imgs/"); menu.attachEvent("onClick", menuClick); menu.loadXML("../common/dhxmenu.xml?e=" + new Date().getTime()); } function menuClick(id) { document.getElementById("item").innerHTML = id + " (" + menu.getItemText(id) + ")"; var ud = menu.getUserData(id, "data"); document.getElementById("item_ud").value = (ud != null ? ud: ""); mid = id; } function update() { var data = document.getElementById("item_new_ud").value; menu.setUserData(mid, "data", data); }