오늘 프로젝트를 진행할 때 문제가 발생했습니다. 여러 확인란 확인란 확인란을 표시해야했지만 최대 6 개만 선택할 수있었습니다. 오랫동안 디버깅을 한 후 마침내 나왔을 때 코드는 다음과 같습니다.
<script language = "javaScript"> var c = 0, 한계 = 6; 함수 doCheck (obj) {obj.checked? c ++ : c-; if (c> limit) {obj.checked = false; 경고 ( "오버"); 기음--; }} </script> <html> <body> <입력 유형 = "checkbox"name = "sample1"onclick = "docheck (this)"> a <input type = "checkbox"name = "sample2"onclick = "docheck (this)"> b <input type = "checkbox"name = "onclick ="intoceck (in input) "" "intocec (in in click)" " 이름 = "sample4"onclick = "docheck (this)"> d <input type = "checkbox"name = "sample5"onclick = "docheck (this)"> e <input type = "checkbox"name = "sample6"onclick = "docheck (this)"> f <input type = "checkbox"name = "inclick ="this) "gockeck (g). name = "sample8"onclick = "docheck (this)"> h <input type = "checkbox"name = "sample9"onclick = "docheck (this)"> i <input type = "checkbox"name = "sample10"onclick = "docheck (this)"> j </body> </html>디스플레이 결과는 다음과 같습니다.