[Javascript] dynamically hide an element

Dong, Roland Roland_Dong at parade.com
Wed Nov 29 18:26:06 CST 2006


Mark,

I followed you example. Works great. Thanks a lot

Sent from my GoodLink synchronized handheld (www.good.com)


 -----Original Message-----
From: 	Mark Kelly [mailto:javascript at wastedtimes.net]
Sent:	Tuesday, November 28, 2006 07:56 PM Eastern Standard Time
To:	javascript at latech.edu
Subject:	Re: [Javascript] dynamically hide an element

On Wednesday 29 November 2006 00:10, Dong, Roland wrote:
> Hello,
>
> I need to dynamically hide and unhide a selection box based on the value
> selected in the first selection box.

I did something almost identical recently with help from this list. In the 
end the best solution (for me at least) was to use CSS classes:

.hidden {display: none;}
.shown {display: block;}

In the HTML:
<div id="selectbox" class="hidden">concealed selectbox here</div>

And in the Javascript for a simple toggle of the visibility I did:

if( myReference.className != 'hidden' ) {
    myReference.className = 'hidden';
    } else {
    myReference.className = 'shown';
    }

This way the space collapses back when the div is hidden.

Hope this helps.

Mark

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list