Hey guys, attached is a zip of my file.
I have a very simple [B]JS script
[code=php]function switchMenu(obj) {
var el = document.getElementById(obj);
if(el.style.display != “block”) {
el.style.display = “block”;
}
else {
el.style.display = “none”;
}
}
The script works fine in both IE6 and Firefox. However, when a menu item is clicked, its sub-menu stays open until you click the menu item again to hide it. I wanted any previously expanded sub-menus to automatically close when a NEW menu item was clicked. So I basically just set all of my sub-menus to have a display style of “none”, instead of “block” when a menu item is clicked. I changed the script to this:
[code=php]function switchMenu(obj) {
this.myvar.style.display = “none”;
this.myvar2.style.display = “none”;
this.myvar3.style.display = “none”;
this.myvar4.style.display = “none”;
var el = document.getElementById(obj);
if(el.style.display != “block”) {
el.style.display = “block”;
}
else {
el.style.display = “none”;
}
}
This script works beautifully in IE6, but now the menu won’t work AT ALL in Firefox! Any ideas?
I am typically not a javascript coder, so I’m sure there’s an easier way to achieve the effect I want without having to list all my obj ID’s, but I didn’t know how else to do it! Hopefully there’s an easy way to get it to work in firefox!
Thanks!
-heather ?
[upl-file uuid=907561fb-49f5-4a30-948b-e85f29761c6d size=2kB]collapse_menu.zip