웹&컴퓨팅

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

x2chi 2007. 6. 19. 18:13
반응형
SMALL
<html>
<head>
<title>m</title>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<script language="javascript">
<!--
function checkall() {
  var form = document.form1;
  for (i=0; i < form.elements.length; i++) {
if (form.elements[i].name =="ex[]") {
    form.elements[i].checked = true;
}
  }
  return;
}
function uncheckall() {
  var form = document.form1;
  for (i=0; i < form.elements.length; i++) {
if (form.elements[i].name =="ex[]") {
  form.elements[i].checked = false;
}
  }
return;
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF">
<form name="form1" method="post" action='ex10.html'>
  <input type="checkbox" name="ex[]" value="1">선택1
  <input type="checkbox" name="ex[]" value="2">선택2
  <input type="checkbox" name="ex[]" value="3">선택3
    <a href="javascript:checkall()">전체 선택</a>
    <a href="javascript:uncheckall()">선택 해제</a>
</form>
</body>
</html>
반응형
LIST

'웹&컴퓨팅' 카테고리의 다른 글

RegExp  (2) 2007.06.19
replace  (2) 2007.06.19
JavaScript  (0) 2007.06.19
Internal Coding Guidelines  (2) 2007.06.19
window.open  (6) 2007.06.19