Hi
Checkboxes:
I need a script that shows a layer when the checkbox is checked and hides a layer when the checkbox is unchecked.
I've tried Dreamweaver's behavior functions but to no avail.
Pls help!
Thanks
Hi
Checkboxes:
I need a script that shows a layer when the checkbox is checked and hides a layer when the checkbox is unchecked.
I've tried Dreamweaver's behavior functions but to no avail.
Pls help!
Thanks
HTML Code:<input type="checkbox" onclick="if (this.checked) {document.getElementById('id1').style.visibility='visible'} else {document.getElementById('id1').style.visibility='hidden'};" /> <div id="id1" style="visibility:hidden">Hi</div>
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
It works like a dream!
Thanks Jon
You could simplify that slightly using the conditional operator:Originally Posted by jscheuer1
However, I'd use something more robust:Code:document.getElementById('id1').style.visibility = this.checked ? 'visible' : 'hidden';
MikeCode:function setVisibility(object, visibility) { if(('string' == typeof object) && document.getElementById) { object = document.getElementById(object); } if(object && object.style) { object.style.visibility = visibility; } } setVisibility('id1', this.checked ? 'visible' : 'hidden');
Bookmarks