Determine which menu item is clicked in javascript

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
mkh100
Beginner
Beginner
Posts: 1
Joined: Wed Apr 05, 2006 11:05 am

Determine which menu item is clicked in javascript

Post by mkh100 »

I have a simple menu like:

Code: Select all

with(milonic=new menuname("FileMenu")){
style=menuStyle;
aI("text=New;url=javascript:menuclick(\"my parameter\",this);");
aI("text=Open;url=http://milonic.com/contact.php;");
aI("text=Delete;url=http://milonic.com/newsletter.php;");
}
And basically want to call a javascript function called menuclick when an item in the menu is clicked. The above code works fine for this and

Code: Select all

function menuclick(text,obj)
{
    alert(text);
}
works as expected, when New is clicked on the above menu. However I also want to manipulate the menu item that was clicked, and realise that this (as a second paramenter) returns the rendered DOM, not as I want a reference to the clicked menu item.

Looking at http://milonic.com/menu_methods.php it looks like gmobj("FileMenu") will get me the menu, but how do I get a reference to the clicked menu item? Is there a way of finding it's id (then I can use gmobj) or a way of getting a reference to the nth item in a menu (that I could then pass as a paramenter)?

What I am trying to do is to build a menu to allow the visibility of elements on the page to be controlled, and need a tick image to be toggled on and off depending upon weather or not that layer is currently showing.

Any help or pointers much appreciated

-Michael
Migru
Milonic Guru
Milonic Guru
Posts: 669
Joined: Tue Nov 01, 2005 8:22 pm
Location: Hamburg - Germany
Contact:

Post by Migru »

Hi

did you check if you find among the Bolt-on modules what you need ?

http://milonic.com/menumodules.php

Michael
Post Reply