# Accordion Menu Help

**URL:** <https://forum.kirupa.com/t/accordion-menu-help/320981>\
**Category:** web dev\
**Created:** [April 7, 2011, 9:51am UTC](https://forum.kirupa.com/t/accordion-menu-help/320981 "2011-04-07T09:51:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fede2008](https://avatars.discourse-cdn.com/v4/letter/f/ba9def/32.png) [@Fede2008](https://forum.kirupa.com/u/Fede2008)\
**Post date:** [April 7, 2011, 9:51am UTC](https://forum.kirupa.com/t/accordion-menu-help/320981/1 "2011-04-07T09:51:43Z")

</div>

Hello to all,  
I have a little problem with my accordion menu and I CRAVE for your help!:krazy:

I try to make this: when you visit my page I need the menu to be all collapsed.  
Also the history of clicks (it remembers which menus where left opened) works fine on IE but not on firefox. :huh:

Here is the js code:

[COLOR=Blue]function add\_menu\_event\_handlers()  
{  
var elems = document.getElementsByTagName(‘h3’);  
for (i = 0; i \< elems.length; i++)  
{  
switch (elems\*.parentNode.className)  
{  
/_case ‘moduletable’:  
case ‘moduletable\_menu’:_/  
case ‘left\_module\_title’:  
case ‘left\_module\_title\_menu’:  
{  
if (elems\*.parentNode.parentNode.parentNode.id == ‘xp-left’)  
{  
xplike\_addEvent(elems\*, ‘click’, function(){menu\_header\_click(this);});  
// menu\_header\_click(elems\*);  
//Load status from cookies and collapse if required  
var cookie\_array = document.cookie.split(’;’);  
for(var j=0; j\<cookie\_array.length; j++)  
{  
var c = cookie\_array[j];  
while (c.charAt(0)==’ ‘) c = c.substring(1,c.length);  
if (c.indexOf(‘xplike\_menu\_status\_’ + elems\*.firstChild.nodeValue.replace(’.’, ‘_’).replace(’ ', '_’)) == 0)  
{  
var menu\_cookie = c.split(’=’)  
if (menu\_cookie.length == 2 && menu\_cookie[1] == ‘1’)  
{  
menu\_header\_click(elems\*);  
}  
}  
}  
}  
}  
}  
}  
}[/COLOR]

And it also has this for the history thing.

[COLOR=Blue]function save\_menu\_status(menu\_title, value, how\_many\_days)  
{  
var date = new Date();  
date.setTime(date.getTime()+(how\_many\_days_24_60_60_1000));  
var expires = “”;  
document.cookie = ‘xplike\_menu\_status\_’ + menu\_title.replace(’.’, ‘_’).replace(’ ', '_’) + ‘=’ + value + expires + ‘; path=/’;  
}[/COLOR]

It might be easy and stupid, I know, but since I’m a designer - not a developer - all look weird to me!  
Any thoughts?
