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: Archived Topics for the old Version 3.0 JavaScript Menu
Forum Topic: Click to view post
Last Updated: Wednesday July 18 2012 - 06:07:20

Disable menu


Poster: Cista
Dated: Wednesday October 23 2002 - 11:20:32 BST

Hello,

Is it possible at runtime, to desable a menu. I'm doing an action and for some reasons, I'd like to disable an (or more) items. If this item has a submenu, this has to stay not usable


Thanks,

bye


Poster: kevin3442
Dated: Thursday October 24 2002 - 0:21:48 BST

This has been a tough one for me as well.

Since the menu_array.js file that defines your menu items is loaded when the page loads, the menu is essentially set up when the page loads and remains static until the page is reloaded or another page is loaded. So, at least as far as I have been able to figure out, you can only achieve the effect of enabling or disabling menus or menu items when a page loads, and cannot change the state of the menus without loading a different page or reloading the same page. The result is basically a set of enabled and disabled menus or menu items that can be applied on a page-by-page basis.

You can do this by having multiple menu_array.js files; each defining a unique set of enabled and disabled menus and items. You would decide which menu_array.js file to load into a page based on what menus and/or items you want to enable on that page. Having the same main menu item selections defined in each menu_array,js file gives the illusion that the menu remains largely the same from page to page.

Or, if you want to stick with one menu_array.js file, you could implement scripts to set conditions that can be tested within the menu_array.js file, and have multiple definitions of the same menu inside if statements that test the conditions, so that the menu that appears matches the conditions present when the page loads. You could use cookies to track changing conditions from page to page, but this would require that your user has cookies enabled. Another approach would be to pass various conditions as part of the URL to each page (to be parsed by scripts when the page loads, but prior to the menu_array.js file loading). Or, if you use frames, you could keep track of the conditions by setting various global variables in a static frame (i.e., the one containing the main menu) and testing those variables in the "body" frame that you load your pages into. I prefer the "scripted conditionals" approach, so that I only have one file to edit when I change my menus. The multiple-array.js file approach is probably easier, but then you have multiple files to edit when you want to change your menus around.

If it sounds complicated, that's probably because it can be! Fortunately, I've read that version 4 of the menuing system will allow dynamic, runtime changes to the menus. That should make achieving this effect much easier when version 4 becomes available. For now, however, the above methods are the only ones I can think of to do this. That's not to say there aren't better ways. There are lots of people whose understanding of this menuing system and coding abilities dwarf my own... maybe someone has a better way that they can share?

Kevin