June 24, 201313 yr Hi there I would like to show or hide some paragraph with checkbox states. I have write following code but it doesn't work : <html> <head> <script type="text/javascript"> function showpara(){ document.getElementById("firstpara").style.visibility = (document.formex.firstcheckbox.checked) ? "visible" : "hidden"; document.getElementById("secondpara").style.visibility = (document.formex.secondcheckbox.checked) ? "visible" : "hidden"; document.getElementById("thirdpara").style.visibility = (document.formex.thirdcheckbox.checked) ? "visible" : "hidden"; } </script> </head> <body> <p id="firstpara">This is First Para</p> <p id="secondpara">This is Second Para</p> <p id="thirdpara">This is Third Para</p> <form id="formex"> <input id="firstcheckbox" type="checkbox" onClick="showpara();"/> <input id="secondcheckbox" type="checkbox" onClick="showpara();"/> <input id="thirdcheckbox" type="checkbox" onClick="showpara();"/> </form> </body> </html> What am i doing wrong? Any help would be appreciated. Edited June 24, 201313 yr by Kamrava
Create an account or sign in to comment