Hello, I have a checkbox marked "Yes" which will show a div with the ID of Yes if checked. The problem is, if it is unchecked nothing happens. I think a simple if else statement would do the trick but I am not sure... I want to show a div on checked and hide on unchecked. This is my code. all help is greatly appreciated. <input name="locationWantMap" type="checkbox" value="Yes" onchange="show('map');show('address')"/> i think ther needs to be an - if checked then show, if unchecked then hide etc..but since the code will not change without a refresh i do not know how to go about doing this. Tim
Hi Tim, I am not sure, but I guess onchange event doesn't do what you need. Try onclick instead and check inside the show() function if checkbox is checked or not... Luk
I think this is wot you are looking for: P.S do inform if it works. <html> <head> <script> function fnchecked(blnchecked) { if(blnchecked) { document.getElementById("divcheck").style.display = ""; } else { document.getElementById("divcheck").style.display = "none"; } } </script> </head> <body> <input type="checkbox" name="fldcheckbox" id="fldcheckbox" onclick="fnchecked(this.checked);"/> <div id="divcheck" style="display:none;"> this is a test file </div> </body> </html>
Hi ChamlingDibya,he hasn't replied, but I found your code to do exactly the same thing and it works for me, thanks very much.James