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: Saturday July 14 2012 - 06:07:23
Hiding Menus Manually / Showing Menus Manually
Poster: nbarth
Dated: Tuesday July 29 2003 - 11:27:56 BST
I have an issue using version 3.5.15. I have a number of menu sets on on page that currently act independantly of eachother. One static menu for the top navigation and various menu sets that are supose to show/hide based on a selection from the top ("Click" and sidebar menu stays until another selection from the top is made). The top navigation is always the same, however when you select an option in the top navigation I would like to be able to hide/show the corresponding menu in the sidebar manually (setting a variable or making some function call) and have it stay visible until another selection is made from the top. I have looked at the code, but it is so obsure that I have a tough time deciphering the meaning of the variables. I have been programming javascript for a number of years so technical answers are ok.
Thanks in advance for any help,
Nicholas
Poster: kevin3442
Dated: Friday August 1 2003 - 6:53:26 BST
Hi Nicholas,
Here are a couple of functions that might help:
Code:
function mm_showMenu(menuName) // + , alwaysVis)
{
var menuNum = getMenuByName(menuName);
if (arguments.length > 1) {
var menuArr = eval("menu" + menuNum);
menuArr[7] = arguments[1];
}
SDiv("menu" + menuNum, 1);
}
{
var menuNum = getMenuByName(menuName);
if (arguments.length > 1) {
var menuArr = eval("menu" + menuNum);
menuArr[7] = arguments[1];
}
SDiv("menu" + menuNum, 1);
}
mm_showMenu() takes the name of the menu you want to open as it's first parameter (menuName), and the Always Visible state as an optional second parameter (alwaysVis). For example, suppose you want to open a menu named "sidemenu". You would call:
Code:
mm_showMenu('sidemenu', 1);
The 1 in the second parameter sets the menu's Always Visible property, so the menu will not close until you do so programatically, using the mm_hideMenu() function, shown below.
Code:
function mm_hideMenu(menuName) // + , alwaysVis)
{
var menuNum = getMenuByName(menuName);
if (arguments.length > 1) {
var menuArr = eval("menu" + menuNum);
menuArr[7] = arguments[1];
}
SDiv("menu" + menuNum, 0);
}
{
var menuNum = getMenuByName(menuName);
if (arguments.length > 1) {
var menuArr = eval("menu" + menuNum);
menuArr[7] = arguments[1];
}
SDiv("menu" + menuNum, 0);
}
mm_hideMenu() does what it suggests: hides the named menu. If you wanted to close "sidemenu" you would call
Code:
mm_hideMenu('sidemenu', 0)
Note that the 0 to clear the Always Visible property is not really necessary (you can actually programatically hide a menu even if it's Always Visible property is set), but it makes logical sense, especially if you want to open the same menu for some other reason, then have it disappear automatically when the user mouses out of it.
Hope that helps,
Kevin