getting a menu to display via a function

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
User avatar
cubefree
Super Advanced
Super Advanced
Posts: 82
Joined: Fri Aug 01, 2003 3:16 am
Location: Seattle, WA
Contact:

getting a menu to display via a function

Post by cubefree »

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://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: Select all

<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... why?

Thanks a million Lira.
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

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
User avatar
cubefree
Super Advanced
Super Advanced
Posts: 82
Joined: Fri Aug 01, 2003 3:16 am
Location: Seattle, WA
Contact:

Post by cubefree »

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.
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

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: Select all

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

Code: Select all

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: Select all

var menuPosition = gpos( gmobj("Milonic") );

try

Code: Select all

var menuPosition = gpos(gmobj("menu" + getMenuByName("Milonic")));
Hope that made sense, and hope it helps.

Kevin
User avatar
cubefree
Super Advanced
Super Advanced
Posts: 82
Joined: Fri Aug 01, 2003 3:16 am
Location: Seattle, WA
Contact:

Post by cubefree »

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: Select all

<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: Select all

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: Select all

menuDisplay(_mnu,_show){_gmD=gmobj("menu"+_mnu);
Last edited by cubefree on Thu May 06, 2004 6:46 pm, edited 1 time in total.
scoobyd
Beginner
Beginner
Posts: 6
Joined: Wed May 05, 2004 7:29 pm

Same thing

Post by scoobyd »

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.
User avatar
cubefree
Super Advanced
Super Advanced
Posts: 82
Joined: Fri Aug 01, 2003 3:16 am
Location: Seattle, WA
Contact:

Post by cubefree »

Andy,

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

Maybe you could check post, 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!
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

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: Select all

<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
Post Reply