Board Logo

Load menu from onClick event
ras - 11/26/2003 at 02:47 PM

I'd like to be able to launch a menu from OnClick event associated with an image in an anchor. Is this possible?


ras - 11/26/2003 at 02:51 PM

Or make the menu invisible until I need it...


BigJ - 2/13/2004 at 07:12 PM

add the following two functions to the menu.js file:

// --------------------------------------------------------------------------------
function show_menu(menu_id){
// hide the menu if it is visible
if(A_MENUS[menu_id].a_children[0].e_oelement.style.visibility == 'visible'){
hide_menu(menu_id);
return;
}
// hide any other elements
for (var i = 0; i < A_MENUS.length; i++){
if(i != menu_id) hide_menu(i);
}
// make root level visible
for (var n_order = 0; n_order < A_MENUS[menu_id].a_children.length; n_order++)
A_MENUS[menu_id].a_children[n_order].e_oelement.style.visibility = 'visible';
}

// --------------------------------------------------------------------------------
function hide_menu(menu_id){
// make root level invisible
for (var n_order = 0; n_order < A_MENUS[menu_id].a_children.length; n_order++)
A_MENUS[menu_id].a_children[n_order].e_oelement.style.visibility = 'hidden';
}


then for your onClick event call:

onClick="show_menu(0)"

for whatever item you set this event to, it will cause it to open the menu on the first click, and close it on the second click

if you have multiple menus, 0 is the first menu loaded, 1 the second, etc. The function will close any open menus when opening a different one.

finally, you need to change the following line in the 'menu' function:

// make root level visible
for (var n_order = 0; n_order < this.a_children.length; n_order++)
this.a_children[n_order].e_oelement.style.visibility = 'visible';

to read:

// make root level invisible
for (var n_order = 0; n_order < this.a_children.length; n_order++)
this.a_children[n_order].e_oelement.style.visibility = 'hidden';

hint: the line is at the end of the function in menu.js


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/