know the number of links in a sub menu

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
rmamidipally
Advanced
Advanced
Posts: 10
Joined: Tue Feb 21, 2006 3:35 pm

know the number of links in a sub menu

Post by rmamidipally »

Hi,

I am using lecenced version of Milonic menu.
In mycase I get the links in a submenu dynamically.
I am using teh divhider.js .
I have make the div hide based on the number of links.
Ex:
If a sub menu has 12 links I need not hide the div.
If it has 13 links I have to.Because under teh 13 link there is the select box.

Is there any way I can know the number of links in a sub menu?

Plz help me.

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

Post by Andy »

Hi,

Try something like this:

Code: Select all

<script>

menuname="Main Menu";
menunumber=getMenuByName(menuname);
alert(_m[menunumber][0].length)

</script>
Assuming you want to know the number of items inside "Main Menu" - Just change the menu name in order to get the number of items from another menu
rmamidipally
Advanced
Advanced
Posts: 10
Joined: Tue Feb 21, 2006 3:35 pm

How to know parent menu?

Post by rmamidipally »

Thank you Andy. :D
My problem is solved.

I have another issue. Please help me in this also.

I have a sub menu link, same in two menus.
But for the same link I have to invoke different actions based on the menu it is being called from.How to know the parent menu?


Ex:

I have two menus A and B.
C is the sub menu link that exists in both A and B.
If C of A is clicked I should call D and if C of B is clicked I should call E.
For that I want to know the parent menu of the link being clicked.


Please help me.

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

Post by Andy »

It's as easy as pie:

getParentMenuByItem(itemReference)

Try this:

Code: Select all

alert(getParentMenuByItem(_itemRef));
Should return the number of the parent menu, if you want the parent menu name, the try this:

Code: Select all

alert(_m[getParentMenuByItem(_itemRef)][1]);
Hope this helps,
Andy
rmamidipally
Advanced
Advanced
Posts: 10
Joined: Tue Feb 21, 2006 3:35 pm

Post by rmamidipally »

Hi Andy,

getParentMenuByItem(_itemRef)

what is the _itemRef in the above piece of code.
Is it "Name of the sub menu"??

Thanks,
Ravi.
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 variable that contains the reference number of the current selected menu item.

If no item is selected its value is -1
Post Reply