Show Layer / Hide all others
Posted: Wed Mar 08, 2006 10:03 pm
My experience with javascript is quite limited, but I'm trying to write a piece of code that shows a layer when a checkbox is clicked, and hides all other layers, here is my (incorrect) code. I can get it to show / hide the layers fine, but as for hiding all other layers (all layer id's are contained in the boxes array) I can't get it to do this, any help would be appreciated, thanks.
Code: Select all
function showMe(id, chk) {
var obj = document.getElementById(id), boxes = ["modu5", "modu112", "modu4", "modu1", "modu14", "modu11", "modu10", "modu13"];
document.getElementById(boxes[1]).style.display = "block";
if (chk.checked==true) {
for (var n = 1; n < boxes.length; n++) {
var ob = document.getElementById(boxes[n]);
ob.style.display = "none";
}
obj.style.display = "block";
} else {
obj.style.display = "none";
}
}