Vebers Posted September 18, 2005 Report Posted September 18, 2005 <script LANGUAGE="JavaScript"> <!-- Begin var checkflag = "false"; function check(field) { if (checkflag == "false") { for (i = 0; i < field.length; i++) { field[i].checked = true;} checkflag = "true"; return "Neatzīmēt visu"; } else { for (i = 0; i < field.length; i++) { field[i].checked = false; } checkflag = "false"; return "Atzīmēt visu"; } } // End --> </script> <input type="checkbox" name="list[]" value="1"/> <input type="checkbox" name="list[]" value="2"/> <input class="button" type=button value="Atzīmēt visu" onClick="this.value=check(this.form.list)"/> kā lai panāk to ka lai atzīmējas visi checkboxi ? ir tā ka checkbox'am name=list tad darbojas, bet man nepiecieshams vinjus ievaakt kaa array...
Delfins Posted September 18, 2005 Report Posted September 18, 2005 var chBoxes = document.getElementsByTagName('INPUT'); for ( i in chBoxes ) { var o = chBoxes[i]; if ( o && o.type && o.type == "checkbox" ) { o.checked = true; } }
Recommended Posts