Found a handy function at The Javascript source and want to modify it for variables (name,range1,range2) in within the function. The script however does not work after my mod. As far as I can see with error searching it has to do with the name variable. Can anyone see what is wrong?
Original working code:
Modified codeHTML Code:<HEAD> <SCRIPT LANGUAGE="JavaScript"> function checkAll() { for (var j = 1; j <= 14; j++) { box = eval("document.checkboxform.C" + j); if (box.checked == false) box.checked = true; } } // End --> </script> </HEAD> <BODY> <center> <form name=checkboxform> <input type=checkbox name=C1> C1<br> <input type=checkbox name=C2> C2<br> <input type=checkbox name=C3> C3<br> <input type=checkbox name=C4 checked>C4<br> <input type=checkbox name=C5 checked>C5<br> <br> <br> <input type=button value="Check All" onClick="checkAll()"><br> <br> <input type=button value="Switch All" onClick="switchAll()"><br> </form> </center>
HTML Code:<HEAD> <SCRIPT LANGUAGE="JavaScript"> function checkAll(start,stop,name) { for (var j = start; j <= stop; j++) { box = eval(name + j); if (box.checked == false) box.checked = true; } } // End --> </script> </HEAD> <BODY> <center> <form name=checkboxform> <input type=checkbox name=C1> C1<br> <input type=checkbox name=C2> C2<br> <input type=checkbox name=C3> C3<br> <input type=checkbox name=C4 checked>C4<br> <input type=checkbox name=C5 checked>C5<br> <br> <br> <input type=button value="Check All" onClick="checkAll(1,2,document.checkboxform.C)"><br> <br> <br> </form> </center>



Reply With Quote




Bookmarks