joelr
12-17-2002, 03:58 AM
I have two div tags in my HTML, all they do is encapsulate sections that I want to be able to hide/show via Javascript. Using the following script, only the first LAST div section can be identified. I've tried switching the order of the div tags, and still, only the last one is found. Can anyone guess what the problem might be, or show me a working example of how to do this with more than one div tag? BTW, the problem occurs on Mozilla 1.2.1 as well as IE 6.
function getStyleObject(objectId) {
// cross-browser function to get an object's style object given its id
if(document.getElementById && document.getElementById(objectId)) {
// W3C DOM
return document.getElementById(objectId).style;
} else if (document.all && document.all(objectId)) {
// MSIE 4 DOM
return document.all(objectId).style;
} else if (document.layers && document.layers[objectId]) {
// NN 4 DOM.. note: this won't find nested layers
return document.layers[objectId];
} else {
return false;
}
}
function changeObjectVisibility() {
var angleField = getStyleObject("angleSection");
var monthMenu = getStyleObject("monthSection");
angleField.visiblity = 'hidden';
monthMenu.visibility = 'hidden';
}
function getStyleObject(objectId) {
// cross-browser function to get an object's style object given its id
if(document.getElementById && document.getElementById(objectId)) {
// W3C DOM
return document.getElementById(objectId).style;
} else if (document.all && document.all(objectId)) {
// MSIE 4 DOM
return document.all(objectId).style;
} else if (document.layers && document.layers[objectId]) {
// NN 4 DOM.. note: this won't find nested layers
return document.layers[objectId];
} else {
return false;
}
}
function changeObjectVisibility() {
var angleField = getStyleObject("angleSection");
var monthMenu = getStyleObject("monthSection");
angleField.visiblity = 'hidden';
monthMenu.visibility = 'hidden';
}