PDA

View Full Version : Switch Menu - Default to an open menu



noyellatmonkeys
02-06-2007, 06:46 PM
1) Script Title: Switch Menu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/switchmenu.htm

3) Describe problem: Hello, what i would like to have is that the first menu is defaulted to open when someone first gets to the menu. for instance on your demo, the "site menu" tab would automatically be open.

Im using switch menu to display pricing http://www.urbantrackers.com/bedding-detail.asp?Vid=D&style_id=P
and i would like for the first available menu (in this case comforter sets) to be open.

Thank you,

~ Moe

Bob90
02-07-2007, 04:44 PM
Just add


style="display:block;"

to the sub section you want open when you start.

:)

adam2003w
12-11-2007, 08:19 PM
you can do a style="display: block;" ... but if you use the persistent menu, then you will have two default menus open the next time you click on a page ...

... so I tweaked the code so now if the persistent cookie is empty it loads a default menu...



if (persistmenu=="yes"){

var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname

var cookievalue=get_cookie(cookiename)

if (cookievalue!="")
document.getElementById(cookievalue).style.display="block";
} else {
document.getElementById("sub1").style.display="block";
}
}

adam2003w
12-11-2007, 08:32 PM
there was a slight but... here is the corrected code


function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="") {
document.getElementById(cookievalue).style.display="block"
} else {
// put your initial menu here
document.getElementById("sub1").style.display="block";
}
}
}