Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Check if layer is visible, if not show select box

Posted on 2004-09-22
4
Medium Priority
?
191 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
3 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

877 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