View Full Version : Add a column for Switch Menu

07-02-2008, 08:03 PM
I want to add a second column for the switch menu. Any ideas on how to do that?


07-03-2008, 02:50 PM

Here is the page I want to modify. The first column works like a charm. The second column opens, but doesn't close when the next link is clicked. How can I fix that?

07-03-2008, 03:16 PM
You seem to have 2 divs with the ID masterdiv. What JavaScript is doing is it's looking at only the first div to see if any are currently open, because ID's are unique and there is only suppose to be one unique ID per page.

To fix this, change the second masterdiv to something like masterdiv2. You then need to change the SwitchMenu function to this:

function SwitchMenu(obj){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
var ar2 = document.getElementById("masterdiv2").getElementsByTagName("span");
if(el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
for (var i=0; i<ar2.length; i++){
if (ar2[i].className=="submenu") //DynamicDrive.com change
ar2[i].style.display = "none";
el.style.display = "block";
el.style.display = "none";

07-03-2008, 08:09 PM
Awesome. Thanks so much!