Want to get Parent of a menu

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
Godzidave
Beginner
Beginner
Posts: 9
Joined: Tue Oct 04, 2005 2:27 pm

Want to get Parent of a menu

Post by Godzidave »

Hi, I have two menus (one is use like a tooltip message), and for this tooltip menu I want to know which menu is this menu parent.

For example, here is my code
with(milonic=new menuname("Menu1")){
alwaysvisible=1;
left=400;
style=menuStyle;
top=30;
orientation="horizontal";
aI("text=David;type=dragable;pointer=move;showmenu=mnuDavid");
}
with(milonic=new menuname("Menu2")){
alwaysvisible=1;
left=400;
style=menuStyle;
top=60;
orientation="horizontal";
aI("text=Michel;type=dragable;pointer=move");
}
with(milonic=new menuname("mnuTooltip")){
left="offset=20";
style=tooltipStyle;
orientation="horizontal";
aI("text=David Lavallée");
}
Here, Menu1 have mnuToolTip as a tooltip menu, and I want to find a way that when I have the item aI("text="David Lavallée"); from the _mi array, I want to find his parent.

Hope I'm clear...

If anybody could help, would be much appreciate

Thanx[/quote]
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Hi,

The following should return the reference number for a menuitems parent menu:

var parentMenu=getParentMenuByItem(_itemRef)

Then, you can call this menus array by either _m[parentMenu] or the object itself by gmobj("menu"+parentMenu)

Hope this helps,
Andy
Godzidave
Beginner
Beginner
Posts: 9
Joined: Tue Oct 04, 2005 2:27 pm

Post by Godzidave »

Yeah, I found this function by searching the web site... but my question was more about how getting the _itemref?? Sorry if I did not make myself clear... :oops:

I'm french so sometime, I can't explain my question real clear...

Hope i'm clear this time :)
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

_itemRef is a global value that is always -1 unless you a menu item is active in which case it is the reference number to the menu item.

It's all pretty much automatic
Godzidave
Beginner
Beginner
Posts: 9
Joined: Tue Oct 04, 2005 2:27 pm

Post by Godzidave »

Oh, didn't know about that.

Thanx, I'll give it a try!! :)
sbraun
Beginner
Beginner
Posts: 7
Joined: Wed Dec 06, 2006 4:03 am

Post by sbraun »

Andy wrote:Hi,

The following should return the reference number for a menuitems parent menu:

var parentMenu=getParentMenuByItem(_itemRef)

Then, you can call this menus array by either _m[parentMenu] or the object itself by gmobj("menu"+parentMenu)

Hope this helps,
Andy




Hello Andy,
I don't know javascript, but I'de like to use this function "var parentMenu=getParentMenuByItem(_itemRef)"

Where do I use it and how?

Thanks for any...
sbraun
rjmjr9
Advanced
Advanced
Posts: 20
Joined: Sat Oct 28, 2006 9:32 pm

Post by rjmjr9 »

Andy wrote:_itemRef is a global value that is always -1 unless you a menu item is active in which case it is the reference number to the menu item.

It's all pretty much automatic

If I understand you -

_itemref is the item number of an item within a speciifc menu and it not an array of all items of all menus on a page. For ex:

menu 1 has 3 items. each item has a showmenu to show a sub menu.

the _itemref that is equal 1 for menu 1 is the first item that is listed in the menu data file.

SO the _itemref that is equal to 1 for a submenu means that it is the first menu item listed in the menu data file for that sub menu. it does not consider the parent menu. _itemref refers only to the menu item wher it was called.

therefore, in this case

aI("clickfunction=getParentMenuByItem(3);"); in the third item on the third submenu of menu 1 will return the parent "menu1"

Is this correct:

If not could you explain how items get their _itemref.

thanks.
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

If I understand you

_itemref is the item number of an item within a speciifc menu and it not an array of all items of all menus on a page. For ex:

menu 1 has 3 items. each item has a showmenu to show a sub menu.

the _itemref that is equal 1 for menu 1 is the first item that is listed in the menu data file.

No, _itemRef is the global item number so if there are 100 menu items in the whole of the menu and the last menu item is highlighted, _itemRef will have a value of 99 (99 because 0 is counted as 1 and so on)

In irder to return the items location within the menu, you would need to use a function such as this:

Code: Select all

function mm_returnItemPos(i){
	var M=_m[_mi[i][0]][0]
	for(var a=0;a<M.length;a++)if(M[a]==i)return a;
	return -1
}
Post Reply