Solved

Check if layer is visible, if not show select box

Posted on 2004-09-22
4
180 Views
Last Modified: 2008-03-10
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
0
Comment
Question by:dotIT
4 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 12126472
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
 

Author Comment

by:dotIT
ID: 12146732
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
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 12173165
Closed, 250 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now