Check if layer is visible, if not show select box

First, I am VERY VERY new to javascript.

Layer1 displays at the click of a link (toggle display=none/inline), and hides any select boxes in the vacinity.
Layer1 contains a a link that opens Layer2. There are then two layers opened at the same time.

Upon click of close button, I need to determine if iether layer1 or layer2 is open to decide whether
or not to show the select box again. If one of the layers is open, do not show the select box if none are open
show the select box.

This is what I am working with, How can I do this:

<script type="text/javascript">
<!--
var z = 1;

// shows layer, hides select boxes
function lnxInfo(){  
//layer 1, contains the link to the layer2
document.getElementById("lnx").style.display = "inline"
document.getElementById("dbto").style.display = "none"
document.getElementById("ptab").style.display = "none"
info2.style.zIndex = ++z;
}
// layer 2
function csvInfo(){
document.getElementById("cinfo").style.display = "inline"
document.getElementById("dbto").style.display = "none"
document.getElementById("ptab").style.display = "none"
document.getElementById("sby").style.display = "none"
cinfo.style.zIndex = ++z;
}

// hides layer, shows select boxes
function closelnxinfo(){
// layer 1
document.getElementById("lnx").style.display = "none"
document.getElementById("dbto").style.display = "inline"
document.getElementById("ptab").style.display = "inline"
}
// layer 2
function closecsvinfo(){
document.getElementById("cinfo").style.display = "none"
document.getElementById("sby").style.display = "inline"
document.getElementById("dbto").style.display = "inlne"
document.getElementById("ptab").style.display = "inline"}

// bring to front
var z = 1;
function up(info) {
  info.style.zIndex = ++z;
}

// -->
</script>

Thanks in advance
dotITAsked:
Who is Participating?
 
ee_ai_constructConnect With a Mentor Commented:
Closed, 250 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0
 
RoonaanCommented:
You could have two global variables telling you which of the layers would be open, and an update_display function action on their values:

var lay1_vis = false;
var lay2_vis = true;

function change(layer_num, visible)
{
  if(layer_num == 1)
    lay1_vis = visible;
  if(layer_num == 1)
    lay2_vis = visible;
  update_display();
}

function update_display()
{
  document.getElementById("lnx").style.display = lay1_vis ? "inline" : "none";
  ..
  ..
  document.getElementById('theselectionboxyouwheretalkingabout').style.display = (lay1_vis || lay2_vis) ? "none" : "inline";
}



my 1.26cts. ;-)

regards

-r-
0
 
dotITAuthor Commented:
Thanks for the input Roonaan, but I got a little confused with your code so I searched the site and came up with the following:

function closelayer2(){
document.getElementById("layer2").style.display = "none"
    if (document.layers[layer1].style.display == 'none'){        // if layer1 is closed
      document.getElementById("selectboxinquestion").style.display = "inline"
    }
}

i got it from here:
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20660391.html?query=if+layer+is+visible&topics=87

It works great
0
All Courses

From novice to tech pro — start learning today.