Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Check if layer is visible, if not show select box

Posted on 2004-09-22
4
184 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

809 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