HTML Question

Thraxen

Diamond Member
Dec 3, 2001
4,683
1
81
What I need to do is set up a form where certain layers appear when certain checkboxes are checked and then disappear if the same boxes are unchecked. I can get the layer to appear when the boxes are checked (******), but can't get them to hide again when the box is unchecked. I need someone to give me an example of some code that can be used to do this.

Thanks!
 

DJFuji

Diamond Member
Oct 18, 1999
3,643
1
76
Thraxen, post your code. You can do what you're talking about fairly easily using javascript. Just make the ****** event of the checkbox call a js function. The JS function will show or hide the layer depending on the current state of its visibility.
 

Thraxen

Diamond Member
Dec 3, 2001
4,683
1
81
Sorry about the late reply, but here is the basic code with which I'm working. Keep in mind I don't know crap about HTML :) Anyway, I just need to see how to make a layer appear and then disappear based on a check box:

 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
Here's a simpler if less legible version of MrChad's code. :)

It's probably better to use visibility because display can be any number of things.

For some reason defaultChecked wasn't working so I had to use body on_Load to set the default for the checkbox (enabled by default since the div is enabled by default in my example).

To make the div default to off, use:

<div id="testArea" style="visibility: hidden">
and then remove the on_Load part.

OK, apparently when you refresh the page, the state of the checkbox is kept, at least in my browser. So you may need to keep the on_Load and force the checkbox off at page start. Whatever you want.