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

Passing Parent Menu Variable to a Sub-Menu


Poster: jetbird
Dated: Friday October 24 2003 - 17:52:28 BST

Is it possible to pass a variable to a sub-menu from a parent menu.


.
.Parent Menu
.
aI("text=Parent Menu;showmenu=ChildMenu;onfunction=setM(1);");
.
.
.


.
.Child Menu
.
aI("text=Child Menu;url=http://www.hello.com/?"+mVal+";");
.
.
.


function setM(t){
mVal=t;
}



Is there any way of doing this?


thanks!


Jeff


Poster: kevin3442
Dated: Friday October 24 2003 - 18:21:20 BST

Hi Jeff,

As far as I know, you can't do it the way you've suggested, mainly because the menus are generated when the page loads. You may be able to change the url of a menu item programatically, but I've never tried that, so I'd have to look into that a bit more (anyone else tried that?).

Another possibility is: Use your setM() function to set the global mVal (or whatever else) with your parent menu's onfunction call, as you've already designed. Then, instead of url=http://yada_yada_yada, set the child menu's url to a function call, like url=javascript:setUrl(); (so it'd be like an onclick). The setUrl() function could then change the page's href according to the global mVal (or others) that you set in the parent menu.

Hope that helps,

Kevin


Poster: Andy
Dated: Monday October 27 2003 - 18:53:54 GMT

Here is a copy of how your data file should look.

Note though that this will not yet be possible until we release the next version of the menu. Current is Version 5.0 RC18 so anything after that will contain the new updates. We are hoping for a full production release in the next few days.

Code:
_scrollAmount=5      // Used for Netscape 4 scrolling
_scrollDelay=10        // Used for Netscape 4 scrolling

_menuCloseDelay=500  // The delay for menus to remain visible on mouse off
_menuOpenDelay=150   // The delay for opening menus on mouse over
_subOffsetTop=0;     // Sub menu offset Top position
_subOffsetLeft=0;  // Sub menu offset Left position

with(vertStyle=new mm_style()){
     onbgcolor = "#ffffcc";
       oncolor = "black";
    offbgcolor = "#5082e6";
      offcolor = "#ffffff";
   bordercolor = "#000000";
   borderstyle = "solid";
separatorcolor = "black";
separatorsize = 1;
       padding = 3
       borderwidth=1
      fontsize = "75%";
     fontstyle = "normal";
    fontfamily = "arial, verdana, tahoma";
      subimage = "/images/arrow.gif";
}

function setM(t){
   mVal=t;
}

function changeURL(){
   _mi[_itemRef][2]=_mi[_itemRef][2]+mVal // change the URL for this menu item
   
   txt="The link is now: "+_mi[_itemRef][2]
   +"\n The text is: "+_mi[_itemRef][1]
   +"\n This menu reference is: "+_mi[_itemRef][0]
   +"\n This menu name is: "+_m[_mi[_itemRef][0]][1]
   
   alert(txt) // just showing some variables
   
}

with(main=new menuname("mainmenu")){
top = 5;
style = vertStyle;
alwaysvisible = 1;
aI("text=Main 1;showmenu=sub1;onfunction=setM(1);");
aI("text=Main 2;showmenu=sub2;onfunction=setM(2);");
aI("text=Main 3;showmenu=sub3;onfunction=setM(3);");
}

   with(main=new menuname("sub1")){
   style = vertStyle;
   aI("text=Menu 1 Item 1;clickfunction=changeURL();url=http://www.milonic.com/;");
   aI("text=Menu 1 Item 2;clickfunction=changeURL();url=http://www.milonic.com/;");
   aI("text=Menu 1 Item 3;clickfunction=changeURL();url=http://www.milonic.com/;");
   }
   
   with(main=new menuname("sub2")){
   style = vertStyle;
   aI("text=Menu 2 Item 1;clickfunction=changeURL();url=http://www.milonic.com/;");
   aI("text=Menu 2 Item 2;clickfunction=changeURL();url=http://www.milonic.com/;");
   aI("text=Menu 2 Item 3;clickfunction=changeURL();url=http://www.milonic.com/;");
   }
   
   with(main=new menuname("sub3")){
   style = vertStyle;
   aI("text=Menu 3 Item 1;clickfunction=changeURL();url=http://www.milonic.com/;");
   aI("text=Menu 3 Item 2;clickfunction=changeURL();url=http://www.milonic.com/;");
   aI("text=Menu 3 Item 3;clickfunction=changeURL();url=http://www.milonic.com/;");
   }
drawMenus()





Regards
Andy


Poster: Hergio
Dated: Wednesday October 29 2003 - 13:11:54 GMT

You definetly are a mad man there Andy. You weren't kidding when you said you've designed this menu to be a platform that exposes lots of tools to developers. Nice job.


Poster: Andy
Dated: Wednesday October 29 2003 - 13:30:15 GMT

Mad man :?: - Heh I like it :D

Yeah, the structure of the menu has been built in such a way as to allow for pretty much any property to be viewed and changed.

The sample at http://www.milonic.com/menusample.php?sampleid=15 demonstrates this quite well.

I'm currently rewriting milonic_src.js to accept custom properties that users can use. Something like
Code:
aI("text=Menu;custom=anything;");
This will make things even more interesting.

Watch this space folks.

Cheers
Andy


Poster: Hergio
Dated: Wednesday October 29 2003 - 13:37:00 GMT

You gotta be kidding me! Thats awesome. So essentially, what will that do? Where will it place those custom tags? Will it be like customTag=customVal in the menu will put a customTag="customVal" into the HTML element? So if we want we can do classes, styles, onclicks, onfocuses, etc etc?