인터넷정보

체크박스 전체선택 / 전체해제

알 수 없는 사용자 2007. 10. 18. 13:42
http://oxtag.com/html/ex/ex/ex4.html

  1. <SCRIPT LANGUAGE="JavaScript">
  2. <!--
  3. function allcheck(formname,boxname,bool) {
  4.     form = eval(formname) ;
  5.     flen = form.elements.length ;
  6.     for( i=0 ; i<flen ; i++ ) {
  7.      if(form.elements[i].name == boxname ) {
  8.              form.elements[i].checked = bool ;
  9.          }
  10.         }
  11. }
  12. //-->
  13. </SCRIPT>
  14. <center>
  15. <FORM name = 'ff' METHOD=get ACTION="form.asp" target="_blank">
  16. <INPUT TYPE="checkbox" NAME="arr" value='a1'>a1<br>
  17. <INPUT TYPE="checkbox" NAME="arr" value='a2'>a2<BR>
  18. <INPUT TYPE="checkbox" NAME="arr" value='a3'>a3<BR>
  19. <INPUT TYPE="checkbox" NAME="arr" value='a4'>a4<BR>
  20. <INPUT TYPE="checkbox" NAME="arr" value='a5'>a5<p>
  21. </FORM>
  22. <a href='javascript:allcheck("ff","arr",true)'>모두체크</a> |
  23. <a href='javascript:allcheck("ff","arr",false)'>모두해제</a>
반응형