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:34

Problems with hiding and showing menus


Poster: stuart
Dated: Monday August 29 2005 - 23:29:16 BST

I am having problems hiding and showing menus.
My knowledge of java is limited but I have managed to get the solution partly working

I am using a frames set-up with three frames.
The top frame has the main navigation menu and the main frame has the submenus. I am trying to get the submenu to open a full contents menu in the left frame.

I have got the basic frames functionality working it's just getting the contents frame to display a menu that I'm having problems with.

I am using some code from Kevin from another posting on this forum

Code:
function mm_showMenu(menuName) // , alwaysVisState = optional. 1=on, 0=off
{
  var menuNum = getMenuByName(menuName);
  if (arguments.length > 1)_m[menuNum][7] = arguments[1];
  menuDisplay(menuNum, 1);
}

function mm_hideMenu(menuName) // , alwaysVisState = optional. 1=on, 0=off
{
  var menuNum = getMenuByName(menuName);
  if (arguments.length > 1)_m[menuNum][7] = arguments[1];
  menuDisplay(menuNum, 0);
}


The problem is that these functions only appear to work if the menu has been initially displayed with it's alwaysvisible property set to true.

For my testing purposes I'm simply calling these functions from a check box in the contents frame.

I have tried using the closeAllMenus() function but without success. I either get an error on the page or the function does nothing.

Help please :(

Re: Problems with hiding and showing menus


Poster: kevin3442
Dated: Monday August 29 2005 - 23:54:45 BST

stuart wrote:
...I am using a frames set-up with three frames.
The top frame has the main navigation menu and the main frame has the submenus. I am trying to get the submenu to open a full contents menu in the left frame.
<...>
The problem is that these functions only appear to work if the menu has been initially displayed with it's alwaysvisible property set to true. ...


Hi Stuart,

The use of those functions can depend on several things, including whether the menu has previously been displayed or not (whether alwaysvisible is on or not). For menus that have not otherwise been displayed, there are some other options.

I'm not entirely sure what you want to do. If you could describe it a little mor fully, or, better yet, post a url to a functioning test site showing what you have so far, I might be able to help.

Also, have you seen this frames-specific example?

Cheers,

Kevin


Poster: stuart
Dated: Tuesday August 30 2005 - 9:59:46 BST

Hi Kevin

Yes I have seen the frames sample and I've got all that working.
I have a top frame with the main menu
I have a main frame with the sub menues.
That all works fine.
What I am now trying to do is to put a table of contents into a side frame (Contents frame)
The contents that will be displayed in the frame will depend on the menu option that the user selects in the main frame

I can load miltiple pages from the sub menuses so updating the main frame and the contents frame at the same time. The contents frame would then be loaded with a different page for each menu. However this does not then work well when the user uses their 'Back' button.

So what I am trying to do is to put all the contents menus into one contents page and then just turn them off and on using some javascript from the main page.

As a test I have set up a check box to run the functions to turn the menu on and off in the contents page. I can make this work from a chck box on the contents page or one on the main page. However in both cases the functions only work if the menu has been loaded into the contants page with the alwaysvisible property set to true.

Hope this all makes sense

Stuart


Poster: kevin3442
Dated: Tuesday August 30 2005 - 16:40:52 BST

Hi Stuart,

Quick question:

Do the menus you've defined in the contents page have specific positions (e.g., left and top) set?

Kevin


Poster: stuart
Dated: Tuesday August 30 2005 - 17:44:56 BST

Hi Kevin

No the only menu with top and left set is the main navigation menu in the header frame.
If I set the Alwaysvisible property to true for all the menus they all appear one on to of the other in the contents frame.

Stuart


Poster: kevin3442
Dated: Tuesday August 30 2005 - 21:55:13 BST

Hi again Stuart,

So... as far as I understand, you have a bunch of menus defined in the contents frame, and your goal is to selectively activate one or another, depending on various conditions. Right?

How do you position (or intend to position) each menu in contents frame? (I ask because it affects how you might open/close them).

Do you have a url I could visit to see the setup you have so far?

Kevin


Poster: stuart
Dated: Wednesday August 31 2005 - 0:25:36 BST

Hi Kevin

Yes your right about what I am trying to do.

What I'd like to achieve is:-
No matter which menu is selected it should always appear in the same place in the contents frame and scroll with the page.

I'm afraid I don't have a url on the internet with this on as yet. I'm working with a local web server on my PC.

I've just shut down that pc so I'll post the page source in the morning.

Stuart


Poster: stuart
Dated: Wednesday August 31 2005 - 9:36:09 BST

Source code from contents frame
Code:
<html>

<head>
<script>

function mm_showMenu(menuName) // , alwaysVisState = optional. 1=on, 0=off
{
  var menuNum = getMenuByName(menuName);
  if (arguments.length > 1)_m[menuNum][7] = arguments[1];
  menuDisplay(menuNum, 1);
}

function mm_hideMenu(menuName) // , alwaysVisState = optional. 1=on, 0=off
{
  var menuNum = getMenuByName(menuName);
  if (arguments.length > 1)_m[menuNum][7] = arguments[1];
  menuDisplay(menuNum, 0);
}




function showcontentsmenu(th)
{
   if(!th.checked)mm_showMenu("Our Calling"); else mm_hideMenu("Our Calling")
}


</script>

</head>

<body>

<SCRIPT language=JavaScript src="milonic_src.js" type=text/javascript></SCRIPT>   
<script   language=JavaScript>
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=mmenuns4.js><\/scr"+"ipt>");      
  else _d.write("<scr"+"ipt language=JavaScript src=mmenudom.js><\/scr"+"ipt>");


</script>


<script>function loadMultiFrames(){if (arguments.length > 0){for (var i=0; i < arguments.length; i++){params = arguments[i].split(" = ");if (params[0].length > 0 && params[1].length > 0) parent[params[0]].location = params[1];}}}
_menuCloseDelay=0;
_menuOpenDelay=0;
_subOffsetTop=-78;
_subOffsetLeft=-204;


with(miniStyle=new mm_style()){
oncolor="#FFFFFF";
onbgcolor="#4F8EB6";
offcolor="#000000";
offbgcolor="#FFFFFF";
padding="3";
separatorsize="1";
borderwidth="1";
fontfamily="verdana";
fontsize="12px";
outfilter="randomdissolve(duration=0.3)";
overfilter="Fade(duration=0.2);Alpha(opacity=90);Shadow(color=#777777', Direction=135, Strength=3)";
ondecoration="";
borderstyle="";
subimage="";
onsubimage="";
bordercolor="#";
subimageposition="";
seperatorcolor="#";
image="";
subimagepadding="";
imagepadding="";
itemwidth="";
}



with(milonic=new menuname("Home")){
style=miniStyle;
alwaysvisible="1";
overflow="scroll";
aI("text=Methodist Churches in Scotland;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=2\", \"main = testpage.asp\");");
aI("text=Circuits;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=2\", \"main = testpage.asp\");");
aI("text=Ministers;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=2\", \"main = testpage.asp\");");
}

with(milonic=new menuname("Synod")){
style=miniStyle;
alwaysvisible="1";
aI("text=Directory;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=3\", \"main = testpage.asp\");");
aI("text=Agenda;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=3\", \"main = testpage.asp\");");
aI("text=Host Church;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=3\", \"main = testpage.asp\");");
aI("text=Previous Events;showmenu=Previous Events;type=tree;image=lblue_blip.gif;overimage=red_blip.gif;");
}

with(milonic=new menuname("Our Calling")){
style=miniStyle;
alwaysvisible="1";
aI("text=Evangelism;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=4\", \"main = testpage.asp\");");
aI("text=Church Life;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=4\", \"main = testpage.asp\");");
aI("text=Learning & Caring;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=4\", \"main = testpage.asp\");");
aI("text=Church & Community;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=4\", \"main = testpage.asp\");");
}

with(milonic=new menuname("Prayer without Ceasing")){
style=miniStyle;
alwaysvisible="1";
aI("text=Prayer Note;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=5\", \"main = testpage.asp\");");
aI("text=Topics for Prayer;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=5\", \"main = testpage.asp\");");
}

with(milonic=new menuname("Contents")){
style=miniStyle;
alwaysvisible="1";
overflow="scroll";
top="0";
left="0";
}

with(milonic=new menuname("Previous Events")){
style=miniStyle;
top="0";
left="0";
aI("text=2005;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=3\", \"main = testpage.asp\");");
aI("text=2004;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=3\", \"main = testpage.asp\");");
aI("text=2003;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=3\", \"main = testpage.asp\");");
}


drawMenus()</script>

<script>
closeAllMenus()
</script>


<br>&nbsp;<p><a href="http://www.milonic.com/">
"DHTML Menu by Milonic"</a></p>


<p><a href="http://www.milonic.com/">
<img height="35" src="milonic_100x35.gif" width="100" border="0"></a></p>


<form>showMenu <input type="checkbox" name="C1" value="ON" onclick="showcontentsmenu(this)" ></form>

</body>
</html>


Poster: Andy
Dated: Thursday September 1 2005 - 9:38:00 BST

The menu needs to be built before it can be viewed, the code for this has been added to the mm_showMenu() function.

I've also removed the alwaysvisible property from the menus but this means that the position of the menus will be off screen. You can either fix the position inside the menu or specify it dynamically using the spos() funciton

Here's your code with a few changes already done, tested and working:

Code:
<html>

<head>
<script>

function mm_showMenu(menuName) // , alwaysVisState = optional. 1=on, 0=off
{
  var menuNum = getMenuByName(menuName);

  if(!_m[menuNum][23])
  {
     BDMenu(menuNum)
     spos(_gm,10,10)
  }
  if (arguments.length > 1)_m[menuNum][7] = arguments[1];
  menuDisplay(menuNum, 1);
}

function mm_hideMenu(menuName) // , alwaysVisState = optional. 1=on, 0=off
{
  var menuNum = getMenuByName(menuName);
  if (arguments.length > 1)_m[menuNum][7] = arguments[1];
  menuDisplay(menuNum, 0);
}


function showcontentsmenu(th)
{
   if(th.checked)mm_showMenu("Our Calling",1); else mm_hideMenu("Our Calling",0)
}


</script>

</head>

<body>

<SCRIPT language=JavaScript src="milonic_src.js" type=text/javascript></SCRIPT>   
<script   language=JavaScript>
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=mmenuns4.js><\/scr"+"ipt>");       
  else _d.write("<scr"+"ipt language=JavaScript src=mmenudom.js><\/scr"+"ipt>");


</script>


<script>function loadMultiFrames(){if (arguments.length > 0){for (var i=0; i < arguments.length; i++){params = arguments[i].split(" = ");if (params[0].length > 0 && params[1].length > 0) parent[params[0]].location = params[1];}}}
_menuCloseDelay=0;
_menuOpenDelay=0;
_subOffsetTop=-78;
_subOffsetLeft=-204;


with(miniStyle=new mm_style()){
oncolor="#FFFFFF";
onbgcolor="#4F8EB6";
offcolor="#000000";
offbgcolor="#FFFFFF";
padding="3";
separatorsize="1";
borderwidth="1";
fontfamily="verdana";
fontsize="12px";
outfilter="randomdissolve(duration=0.3)";
overfilter="Fade(duration=0.2);Alpha(opacity=90);Shadow(color=#777777', Direction=135, Strength=3)";
ondecoration="";
borderstyle="";
subimage="";
onsubimage="";
bordercolor="#";
subimageposition="";
seperatorcolor="#";
image="";
subimagepadding="";
imagepadding="";
itemwidth="";
}



with(milonic=new menuname("Home")){
style=miniStyle;
//alwaysvisible="1";
overflow="scroll";
aI("text=Methodist Churches in Scotland;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=2\", \"main = testpage.asp\");");
aI("text=Circuits;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=2\", \"main = testpage.asp\");");
aI("text=Ministers;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=2\", \"main = testpage.asp\");");
}

with(milonic=new menuname("Synod")){
style=miniStyle;
//alwaysvisible="1";
aI("text=Directory;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=3\", \"main = testpage.asp\");");
aI("text=Agenda;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=3\", \"main = testpage.asp\");");
aI("text=Host Church;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=3\", \"main = testpage.asp\");");
aI("text=Previous Events;showmenu=Previous Events;type=tree;image=lblue_blip.gif;overimage=red_blip.gif;");
}

with(milonic=new menuname("Our Calling")){
style=miniStyle;
//alwaysvisible="1";
aI("text=Evangelism;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=4\", \"main = testpage.asp\");");
aI("text=Church Life;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=4\", \"main = testpage.asp\");");
aI("text=Learning & Caring;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=4\", \"main = testpage.asp\");");
aI("text=Church & Community;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=4\", \"main = testpage.asp\");");
}

with(milonic=new menuname("Prayer without Ceasing")){
style=miniStyle;
//alwaysvisible="1";
aI("text=Prayer Note;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=5\", \"main = testpage.asp\");");
aI("text=Topics for Prayer;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=5\", \"main = testpage.asp\");");
}

with(milonic=new menuname("Contents")){
style=miniStyle;
//alwaysvisible="1";
overflow="scroll";
top="0";
left="0";
}

with(milonic=new menuname("Previous Events")){
style=miniStyle;
top="0";
left="0";
aI("text=2005;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=3\", \"main = testpage.asp\");");
aI("text=2004;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=3\", \"main = testpage.asp\");");
aI("text=2003;url=javascript:loadMultiFrames(\"contents = contents.asp?menuname=3\", \"main = testpage.asp\");");
}


drawMenus()</script>

<script>
closeAllMenus()
</script>


<br>&nbsp;<p><a href="http://www.milonic.com/">
"DHTML Menu by Milonic"</a></p>


<p><a href="http://www.milonic.com/">
<img height="35" src="milonic_100x35.gif" width="100" border="0"></a></p>


<form>showMenu <input type="checkbox" name="C1" value="ON" onclick="showcontentsmenu(this)" ></form>

</body>
</html>


Hope this helps,
Andy