函數doc check(CK name ){
var cks = document . getelementsbyname(‘CK 1‘);
var count = true
for(var I = 0;我& ltcks .長度;i++){
if(cks【I】。已檢查){
count = false
打破;
}
}
如果(計數){
Alert(“必須選擇壹個“);
}
}
& lt/script & gt;
& ltinput type =“checkbox“name =“CK 1“value =“1111“/& gt;1111 & lt;br & gt
& ltinput type =“checkbox“name =“CK 1“value =“2222“/& gt。2222 & ltbr & gt
& ltinput type =“checkbox“name =“CK 1“value =“3333“/& gt。3333 & ltbr & gt
& ltinput type =“checkbox“name =“CK 1“value =“4444“/& gt。4444 & ltbr & gt
& ltinput type =“checkbox“name =“CK 1“value =“5555“/& gt。5555 & ltbr & gt
& ltinput type =“button“value =“check“onclick =“doc check(‘CK 1‘)“/》
可能寫了壹個例子放在妳的代碼裏。此外,壹般來說,壹個組最好具有相同的復選框名稱。Id和值不同。