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

Q983 How can I hide and show a layer when form buttons are pressed?

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

Try:

<script language="JavaScript"><!--
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="show('myId')" value="Show">
<input type="button" onClick="hide('myId')" value="Hide">
</form>

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

©2018 Martin Webb