473,569 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

show/hide layer

Hi there,

I am trying to create a form with an dynamic field that can be shown or hidden.
As I saw for example on google it is possible with JS to show a layer and move
the content underneath that layer further down uppon showing this layer. When a
person closes that layer the content underneath the layer moves up again and
closes the empty space. How is this possible?

I am playing around with some code I am posting with this thread. Could somebody
give me a small push to get closer to my goal?

Thank you in advance,

Merlin

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Show and Hide a Layer</title>
<style type="text/css">
#boxthing { position:relati ve; top:0px; left:0px; width:250px; height:150px;
border:1px #000000 solid; background-color:#FF9999; padding:0.5em; }
</style>
<script type="text/javascript">

function hideLayer(which Layer) {
if (document.getEl ementById) {
// this is the way the standards work
document.getEle mentById(whichL ayer).style.vis ibility = "hidden";
}
else if (document.all) {
// this is the way old msie versions work
document.all[whichlayer].style.visibili ty = "hidden";
}
else if (document.layer s) {
// this is the way nn4 works
document.layers[whichLayer].visibility = "hidden";
}
}

function showLayer(which Layer) {
if (document.getEl ementById) {
// this is the way the standards work
document.getEle mentById(whichL ayer).style.vis ibility = "visible";
}
else if (document.all) {
// this is the way old msie versions work
document.all[whichlayer].style.visibili ty = "visible";
}
else if (document.layer s) {
// this is the way nn4 works
document.layers[whichLayer].visibility = "visible";
}
}

function handleClick(whi chClick) {

if (whichClick == "hide it") {
// then the user wants to hide the layer
hideLayer("boxt hing");

}
else if (whichClick == "show it") {
// then the user wants to show the layer
showLayer("boxt hing");
}

}

</script>
</head>
<body>
<a href="#" onclick="handle Click('show it'); return false">Show Layer</a><br>

<div id="boxthing" style="visibili ty:hidden;">
<a href="#" onclick="handle Click('hide it'); return false">Hide Layer</a><br>
<p>Use the links above to show and hide this layer.<p></div>
tese
</body>
Apr 4 '06 #1
3 6377
"Merlin" <ng*****@fastma il.fm> skrev i melding
news:49******** ****@individual .net...
Hi there,

I am trying to create a form with an dynamic field that can be shown or
hidden.
As I saw for example on google it is possible with JS to show a layer and
move the content underneath that layer further down uppon showing this
layer. When a person closes that layer the content underneath the layer
moves up again and closes the empty space. How is this possible?

I am playing around with some code I am posting with this thread. Could
somebody give me a small push to get closer to my goal?

Thank you in advance,

Merlin

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Show and Hide a Layer</title>
<style type="text/css">
#boxthing { position:relati ve; top:0px; left:0px; width:250px;
height:150px; border:1px #000000 solid; background-color:#FF9999;
padding:0.5em; }
</style>
<script type="text/javascript">

function hideLayer(which Layer) {
if (document.getEl ementById) {
// this is the way the standards work
document.getEle mentById(whichL ayer).style.vis ibility = "hidden";

<snipped/>

Use 'display' instead of 'visibility'...

....style.dippl ay = "none";
....style.dippl ay = "block";

--
Dag.
Apr 4 '06 #2
Dag Sunde wrote:
"Merlin" <ng*****@fastma il.fm> skrev i melding
news:49******** ****@individual .net...
Hi there,

I am trying to create a form with an dynamic field that can be shown or
hidden.
[...]
Use 'display' instead of 'visibility'...

...style.dippla y = "none";
...style.dippla y = "block";


Better to use di*s*play = '' instead of 'block':

...style.displa y = 'none';
...style.displa y = '';
Setting the display property allows it to return to the default (or
whatever has been set via CSS or whatever), and is generic for all display
property values. It is also handy where different browsers set different
defaults for some elements.
--
Rob
Apr 4 '06 #3
"RobG" <rg***@iinet.ne t.au> skrev i melding
news:44******** **************@ per-qv1-newsreader-01.iinet.net.au ...
Dag Sunde wrote:
"Merlin" <ng*****@fastma il.fm> skrev i melding
news:49******** ****@individual .net...
Hi there,

I am trying to create a form with an dynamic field that can be shown or
hidden.

[...]

Use 'display' instead of 'visibility'...

...style.dippla y = "none";
...style.dippla y = "block";


Better to use di*s*play = '' instead of 'block':

...style.displa y = 'none';
...style.displa y = '';
Setting the display property allows it to return to the default (or
whatever has been set via CSS or whatever), and is generic for all display
property values. It is also handy where different browsers set different
defaults for some elements.


True, I should have advised that instead...

--
Dag.
Apr 4 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3192
by: David | last post by:
Hi everyone, Hoping there are some .js/browser experts out there that can help with this weird problem. I have made a swap div routine and applied the events to menu buttons with a closer layer behind the menus. The closer div has a lower index than the submenu divs so it appears behind them. The closer div contains a transparent gif...
3
14423
by: Ryh | last post by:
I have the following scritpt. It hides div layer when mouse is out of the div layer. Inside DIV I have IFRAME box. Unfortuantely it does not work in Mozilla or IE 5.5. It hides div when cursor is inside IFRAME. NOte that IFRAME is inside DIV so it should not hide DIV. It Works fine in IE6.0. Could any one help? Example:
3
5318
by: a1000car | last post by:
I have almost 2 weeks tying to find a solution for this. Please help -How can you SHOW/HIDE an thml-dreamweaver layer from a flash movie button. My html layer name is LAYER1, and my FlashMC botton name is FLBOT1 Now, what is the actionscript that im suppouse to place in the flash button? Please respond, Thanks
2
3361
by: stasteamb | last post by:
Can anyone help with this please? This is a copy of my code. <td width="20%"><div id="Layer1"> <p onclick="MM_showHideLayers('Layer2','','show')">Raymond</p> <p onclick="MM_showHideLayers('Layer2','','show')">Dave</p> <p onclick="MM_showHideLayers('Layer3','','show')">Reggie</p> </div>
1
4155
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. I don`t want to change the way i have used to show and hide layers. check down code :- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
6
16303
elamberdor
by: elamberdor | last post by:
Hi All! Trying to get a drop down hide/show div on a html page triggered by a button in flash. (Intro: Very very Little experience in dynamic flash) setup: html page, flash map on page, button on flash opens info underneath map in a separate div. div that has hide/show content is called "operator" I found this code, but i'm not sure it's...
1
1797
by: liesther2003 | last post by:
Hi i want to show mutli layer by each click, and when i click next layer the first layer should be still display, until maybe 3rd or 4th or 5th layer all are displayed, and at the end when i click somewhere (maybe image) then close all layer. my code are here <script type="text/javascript"> var currlayerId = null; function toglayer(id) ...
2
2134
by: dusk | last post by:
Hi, I have a page with lots of hidden divs which are revealed based on choices made at each 'layer'. So I've used naming convention which represents the order in which each div becomes visible - 'a100', 'a200', 'a300' for the first 'layer'; 'b100', 'b200', 'b300' for the second; 'c100, 'c200', 'c300' for the third ... etc I'm writing...
0
7694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.