Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q984 How can I hide and show a layer when a single form toggle button is pressed?

You are here: irt.org | FAQ | DHTML | Q984 [ previous next ]

Try:

<script language="JavaScript"><!--
var toggle = false;

function show(object) {
    if (document.layers && document.layers[object])
        document.layers[object].visibility = 'visible';
    else if (document.all) {
        document.all[object].style.visibility = 'visible';
        document.all[object].style.zIndex = 100;
    }
}
function hide(object) {
    if (document.layers && document.layers[object])
        document.layers[object].visibility = 'hidden';
    else if (document.all)
        document.all[object].style.visibility = 'hidden';
}
//--></script>

<form>
<input type="button" onClick="if (toggle = !toggle) hide('myId');else show('myId')" value="Show/Hide">
</form>

<div id="myId" style="position: absolute; visibility: visible;">Test</div>

Feedback on 'Q984 How can I hide and show a layer when a single form toggle button is pressed?'

©2018 Martin Webb