复制代码代码如下: 无标题文档 <br>fungsi selectAllDels() <br>{ <br>var allCheckBoxs = document.getElementsByName("preDelCheck"); <br>var desc = document.getElementById("allChecked"); <br>var selectOrUnselect=false; <br>untuk(var i = 0; i < allCheckBoxs.length; i ) <br />{ <br />if(allCheckBoxs[i].checked){ <br />selectOrUnselect=true; <br />pecah; <br />} <br />} <br />jika (selectAtauNyahPilih) <br />{ <br />_allUnchecked(allCheckBoxs); <br />}lain <br />{ <br />_allchecked(allCheckBoxs); <br />} <br />} <br />fungsi _allchecked(allCheckBoxs){ <br />for(var i = 0; i < allCheckBoxs.length; i ) <br />{ <br />semuaCheckBoxs[i].checked = benar; <br />} <br />} <br />fungsi _allUnchecked(allCheckBoxs){ <br />for(var i = 0; i < allCheckBoxs.length; i ) <br />{ <br />allCheckBoxs[i].checked = palsu; <br />} <br />} <br /></skrip> <br></head> <br><badan> <br><p>ujian</p> <br><borang> <br><input type="checkbox" name="preDelCheck" value="cream">ID1<br> <br><input type="checkbox" name="preDelCheck" value="gula" > ID2<br> <br><input type="checkbox" name="preDelCheck" value="sugar">ID3<br> <br><input type="checkbox" name="preDelCheck" value=" gula">ID4<br> <br><input type="checkbox" name="preDelCheck" value="sugar">ID5<br> <br><input type="button" id="allCheck " value="全选/取消全选" onClick="selectAllDels()"> <br></form> <br></badan> <br></html> <br> </div>