Menu Items Text Manipulation
Select Item | (Click menu item to select) |
|
Current Item Text | ||
New Item Text |
Select Item | (Click menu item to select) |
|
Current Item Text | ||
New Item Text |
<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"> </td> <td><div id="item">(Click menu item to select)</div></td> </tr> <tr> <td>Current Item Text</td> <td> </td> <td><div id="item_text"> </div></td> </tr> <tr> <td>New Item Text</td> <td> </td> <td><input id="item_new_text" type="text" value="New Item Text"> <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; document.getElementById("item_text").innerHTML = menu.getItemText(id); mid = id; } function update() { var text = document.getElementById("item_new_text").value; menu.setItemText(mid, text); }