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

getting a menu to display via a function


Poster: cubefree
Dated: Thursday May 6 2004 - 5:06:49 BST

Oh the drain on my brain... please tell this is so simple and my brain is totally fried from radiation...

According to the Milonic support files, http://www.milonic.com/menu_methods.php, but I'm only getting a Integer on the following alerts. NO gpos and no display for menu sample, menu_sample24_ver5_15. ARrrgggh, what gives??

Can someone rub 2 braincells together for me!?

Code:
<script language="JavaScript" type="text/JavaScript">
// page scripts
function loadPage() {
   //mm_showMenu('services');
   menuName = 'Milonic';
   alert(getMenuByName(menuName));
   menuDisplay(gmobj(menuName),1)

var menuPosition = gpos( gmobj("Milonic") );
   for(i=0;i<4;i++) {
      alert(menuPosition[i]);
   }
}
</script>

<body onLoad="loadPage();">


In fact I get an error menuPosition[i]... why?

Thanks a million Lira.


Poster: Ruth
Dated: Thursday May 6 2004 - 6:14:22 BST

I really don't have a clue what you're doing [sort of] but I do remember seeing someplace about not naming things Milonic because that's used somehow in or by the menu? I don't know that this would apply here. And, if this has absolutely no relevance, I'll delete it next time around :)

Ruth


Poster: cubefree
Dated: Thursday May 6 2004 - 6:52:37 BST

I'm just trying to make a submenu display on the page per a function, rather than mousing over a menu item.

I tried the first menu too which is named "Samples" -- same result per my first message.


Poster: kevin3442
Dated: Thursday May 6 2004 - 7:44:31 BST

Hi Cubefree,

I think what'sgoing on is that you are passing an object (the return of gmobj()) as the first parameter to menuDisplay(). But don't feel bad... I think your brain cells are just fine, becasue I see that you're doing it exactly the way the docs on the "Methods and Functions" page describe. Problem is, after having a look, I thing the docs for the menuDisplay() function are wrong. I've been messing with that function since before the docs page appeared, and I'm certain that the first parameter passed to menuDisplay() is an integer, which is used as an index into the _m[] array (look at the function definition in mmenudom.js, and you'll see that the first parameter is passed into the function as _mD, which is used as an index into _m[] menu array). So, you should be able to take the return of getMenuByName() and pass it as the first parameter into menuDisplay(), like so:
Code:
menuName = 'Milonic';
menuNum = getMenuByName(menuName);
menuDisplay(menuNum,1);

or, more directly:
Code:
menuName = 'Milonic';
menuDisplay(getMenuByName(menuName),1)

You may have to pay attention to whether the menu you want to open already has coordinatesw at which to open. If not, it probably won't open (You can set position with the spos() function).

Speaking of which... I think your call to gpos() also has a problem. The example in the docs refers to "menu1" but that's a little confusing... it's not the whole story. "menu1" is really an internal reference... i.e., every menu system has an internal menu1, menu2, etc. But you don't know directly which menu is menu1, which is menu2, etc. You have to get that info out of the menu system as an intermediate step. You do know the menu names you used in your menu_data.js, so you start there. You have to take the text "menu" and append the menu number of the menu of interest. The menu number is the index in the _m[] array where the menu of interest will be found. But how do you get that number??? ... conveniently, it happens to be the return of getMenuByName(), which takes your menu name as a parameter (see... you knew I'd get back to the names, right?). So, in your specific example, instead of
Code:
var menuPosition = gpos( gmobj("Milonic") );

try
Code:
var menuPosition = gpos(gmobj("menu" + getMenuByName("Milonic")));


Hope that made sense, and hope it helps.

Kevin


Poster: cubefree
Dated: Thursday May 6 2004 - 8:29:00 BST

Kevin,

OF course the whole point of this is really how to manipulate a submenus, alwaysvisible property. Is that possible?

Thank you for your elaborate reply. But I've tried it over and over and I've thoroughly read your great posts on the topic with the "menu" concatenation. But nada, mon. I get the alert for "1" which is correct per this sample menu, but nothing else. Try slappin' this code in there...

Code:
<script language="JavaScript" type="text/JavaScript">
// page scripts
function loadPage() {
menuName = 'Milonic';
alert(getMenuByName(menuName));
menuDisplay(gmobj("menu" + getMenuByName("Milonic")));   

var menuPosition = gpos(gmobj("menu" + getMenuByName("Milonic")));
for(i=0;i<4;i++) {
alert(menuPosition[i]);
}

}
</script>
</head>
<body onLoad="loadPage();">


and this below in menu_data.js

Code:
with(milonic=new menuname("Milonic")){
style=menuStyle;
top=101;
left=102;
height=104;
width=105;


I've been trying it in a site I'm building, but that code is getting messy now. So I thought go back to basics... just get it to work in one of the samples you know... but nada, mon.

I DO get alerts for all now, but NO menuDisplay. It is supposed to display the menu, correct?

Your other post says it works, but it's not budging in IE6, Win2000, Version 5.15 - Built: Thursday April 29 2004 - 16:10

Thanks!
The cubist formerly known as ... briancell binar.

PS are you so sure about mmenudom.js... in the function menuDisplay(), it already adds "menu" to the reference, oui oui?

Code:
menuDisplay(_mnu,_show){_gmD=gmobj("menu"+_mnu);

Same thing


Poster: scoobyd
Dated: Thursday May 6 2004 - 17:47:48 BST

I have actually been having somewhat of the same problem and after running through the debugger, the only thing that I found, was that when I used menuDisplay to try and hide it, no matter what when it gets to the line checking for visibility in I believe mmenudom.js it says that the menu ( or div ) has a visiblity of 'HIDDEN', and therefore does not try to hide.

As for 'displaying' the menu, it goes and sets the style.visibility to 'visible' but does not display the menu. I have relatively the same setup as the original poster.


Poster: cubefree
Dated: Thursday May 6 2004 - 18:55:53 BST

Andy,

There seems to be some confusion, albeit mostly mine... in any case.

Maybe you could check post, http://www.milonic.com/forum/viewtopic. ... 8810#18810

Isn't the thrust of this method to manipulate a submenu's alwaysvisible property??

I've tried every method posted in the forum. And still can not get a menu to display and stay. I would just use showmenu=menuname, but there are other menus in between and it cause the submenu I want to dissappear.

Thank you!


Poster: Andy
Dated: Friday May 7 2004 - 12:32:51 BST

Hi,

If you display a menu and you want it to remain on screen you also need to tell it to be alwaysvisible.

The way to do this is to set its array element, here's how:

Code:
<script language="JavaScript" type="text/JavaScript">
// page scripts
function loadPage() {
menuName = 'Milonic';
menuNumber=getMenuByName("Milonic");
menuDisplay(gmobj("menu" + menuNumber),1);
_m[menuNumber][7]=1
var menuPosition = gpos(gmobj("menu" + getMenuByName("Milonic")));
}
</script>


Menu data is stored in the _m array so once you have the appropriate menu number you need to set element 7 to true with _m[menuNumber][7]=1


Hope this helps
Andfy