joc
12-04-2002, 07:05 PM
Hi,
I'm having problems controlling the visibility of a layer (div).
I can only get the layer to appear when I use the layerID explicitly, i.e. "layerBook", but I can't stick the name into a var, i.e. var layerName = "layerBook" doesn't work.
-------------------------------------------------------
Here's the snippet of code:
var sTypeOptions = ["JournalArticle", "Book", "Manuscript"];
function changeField(selectvalue) {
var layerName = "layer" + selectvalue;
var layerNameNet6 = "\'" + layerName + "\'";
for (i=0;i<sTypeOptions.length;i++) {
var thisLayer = "layer" + sTypeOptions[i];
var thisLayerNet6 = "\"" + thisLayer + "\"";
if (selectvalue==sTypeOptions[i]) {
if (document.getElementById&&!document.all) {
//THE FIRST 2 LINES HERE DON'T WORK
//document.getElementById(layerName).style.visibility = "visible";
//document.getElementById(layerNameNet6).style.visibility = "visible";
document.getElementById("layerBook").style.visibility = "visible";
} //if
}//if
else {
//make the other layers hidden
if (document.getElementById&&!document.all) {
document.getElementById(thisLayer).style.visibility = "hidden";
} //if
} //else
} //for
} //changeField
//document.getElementById(layerName).style.visibility = "visible"; //document.getElementById(layerName).style.visibility = "visible";
I'm having problems controlling the visibility of a layer (div).
I can only get the layer to appear when I use the layerID explicitly, i.e. "layerBook", but I can't stick the name into a var, i.e. var layerName = "layerBook" doesn't work.
-------------------------------------------------------
Here's the snippet of code:
var sTypeOptions = ["JournalArticle", "Book", "Manuscript"];
function changeField(selectvalue) {
var layerName = "layer" + selectvalue;
var layerNameNet6 = "\'" + layerName + "\'";
for (i=0;i<sTypeOptions.length;i++) {
var thisLayer = "layer" + sTypeOptions[i];
var thisLayerNet6 = "\"" + thisLayer + "\"";
if (selectvalue==sTypeOptions[i]) {
if (document.getElementById&&!document.all) {
//THE FIRST 2 LINES HERE DON'T WORK
//document.getElementById(layerName).style.visibility = "visible";
//document.getElementById(layerNameNet6).style.visibility = "visible";
document.getElementById("layerBook").style.visibility = "visible";
} //if
}//if
else {
//make the other layers hidden
if (document.getElementById&&!document.all) {
document.getElementById(thisLayer).style.visibility = "hidden";
} //if
} //else
} //for
} //changeField
//document.getElementById(layerName).style.visibility = "visible"; //document.getElementById(layerName).style.visibility = "visible";