Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:04

Here is the theJavascript to disable a menu item at run time

Poster: powlette
Dated: Wednesday October 15 2003 - 15:10:44 BST

If you need to disable menu item, gray it out, and disbale the url you can use this script. It can also restore the url and color.

call it like this:

setMenuItemEnabled("Main Menu", 1, false);

function setMenuItemEnabled(menuname, itemNumber, enabled)
   if (!document.all) return;
   vals = (""+_m[getMenuByName(menuname)]).split(",");
   var item = _mi[parseInt(vals[0])+itemNumber];
   indexName = 1;   indexURL = 2;   indexOffColor = 6;   indexOnColor = 8;   indexBackupURL = 20;
   if (item[indexBackupURL] == undefined) item[indexBackupURL] = item[indexURL];
   if (enabled)
      item[indexURL] = item[indexBackupURL];   item[indexOffColor] = '000000';   item[indexOnColor] = '000000';
      item[indexURL] = 'javascript:';   item[indexOffColor] = '999999';   item[indexOnColor] = '999999';

If you enhance this or find it useful, please let me know
jody __at__

Amended version of dynamically enabling/disabling menu

Poster: schalkley
Dated: Friday September 10 2004 - 9:54:44 BST


Your function was a great help, but I found it only disabled the top level menus and any submenus still appeared. I found here in the forums that you can disable a menu using
but I want to do this dynamically.
I found the index number of the 'type' which is 34, and amended your function as follows.

// disable or enable the Milonic menu.
// __at__ param disable - true to disable, false to enable
function disableMilonicMenu(disable) {
// this is the name from the menu_data.js
var mainMenuName="Main Menu";

// this is the number of top level menu items on the menu not including
// the 'Milonic' that appears in the unlicensed version of the menu.
var numberOfTopLevelMenus = 8;

if (!document.all) return;
indexType=34; indexBackupURL = 20; indexURL = 2;
vals = (""+_m[getMenuByName(mainMenuName)]).split(",");
for (itemNumber=1; itemNumber < numberOfTopLevelMenus+1; itemNumber++)
var item = _mi[parseInt(vals[0])+itemNumber];

if (item[indexBackupURL] == undefined) item[indexBackupURL] = item[indexURL];
if (disable)
item[indexType] = 'disabled';
item[indexType] = 'enabled';

This disables or enables the top level menus (change the two values in the function to suit your site).
There is a bug though. The last menu item is changed to the colour of highlighted.
Anyone fix this?

Stephen Chalkley.

Poster: kevin3442
Dated: Friday September 10 2004 - 10:27:53 BST

Hi Stephen,

You might also take a look at a function called mm_changeItemProperty(), described in detail in this thread. You can use the function to change any property in any menu item dynamically, including setting the type property (34 as you found) to disable and re-enable a menu item.

Hope that helps,