Hiding layers

J

Jason & Juli Cook

I have a layer containing a table. The layer is inside a centered
containing table. If the layer is hidden, I want the form (surrounding
table) to collapse. I want to toggle this effect with a checkbox. I can
get the layer to come on, but not toggle. Also, it starts as hidden and
there is a big gap where the table should be. What do I do?

For the javascript, I've tried different versions of the following:
function ChangeState(){
if(document.getElementById(myCheckBox).checked){
theForm.myLayer.style.display='block';
}
}

My div tag works:
<div id="myLayer" style="display: none;">

My checkbox tag includes the following:
onClick="ChangeState();"
 
M

Martin Honnen

Jason & Juli Cook wrote:

For the javascript, I've tried different versions of the following:
function ChangeState(){
if(document.getElementById(myCheckBox).checked){
theForm.myLayer.style.display='block';
}
}

My div tag works:
<div id="myLayer" style="display: none;">

My checkbox tag includes the following:
onClick="ChangeState();"

<input type="checkbox"
onclick="changeState(this);" ...>

function changeState (checkbox) {
var div;
if (document.getElementById &&
(div = document.getElementById('myLayer'))) {
div.style.display = checkbox.checked ? 'block' : 'none';
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,771
Messages
2,569,587
Members
45,099
Latest member
AmbrosePri
Top