hi everyone: I have a problem with a small function I wrote to practice the getElementbyId method - the function i wrote can be made without this method but i wanted to practice it - why doesn't it run? please try to run it before answer I don't understand what can go wrong? need u guys quickly progfrog <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1255 "> <script type="text/javascript"> function michal(x) { var checky=document.getElementById(x) if (idan.checky.checked) { idan.comment1.style.display="none"; } else { idan.comments1.style.display="block"; } </script> </head> <body> <form id="idan"> <input type="checkbox" id="check1" onclick="michal('check1')" checked /><textarea id="comments1" cols="30" rows="7">I think that</textarea> <br> </form> </body> </html>
function michal(x) { var checky = document.getElementById(x); if(checky.checked) { document.getElementById('comments1').style.display = "inline"; } else { document.getElementById('comments1').style.display = "none"; } } Code (markup): Let me know if you don't understand how it works.
var checky = document.getElementById(x); document.getElementById('comments1').style.display = checky.checked ? "inline" : "none" PHP:
hello, i already replied you in your another thread with same question.. here it is again for you with corrections; <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1255 "> <script type="text/javascript"> function michal(x) { var checky=document.getElementById(x); if (checky.checked) { idan.comments1.style.display="none"; } else { idan.comments1.style.display="block"; } } </script></head> <body> <form id="idan"> <input type="checkbox" id="check1" onclick="michal('check1')" checked /><textarea id="comments1" cols="30" rows="7">I think that</textarea> <br> </form> </body> </html> what fixings i have done in your code: 1) i replaced "if (idan.checky.checked)" with "if (checky.checked)" 2) "s" was missing in the comments spelling idan.comment(s)1.style.display="none"; 3) you missed to close the function end brace } thatz all...