Solved

Check if layer is visible, if not show select box

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

777 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