본문 바로가기
JAVASCRIPT/checkbox의 value 값 체크

자바스크립트로 checkbox 값 체크

by 정윤재 2009. 2. 23.

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
<script>
function sub(){
 var sss = form.sss;
 var conf=   false;
 for(i=0;i<sss.length;i++){
  if(sss[i].checked == true){
   conf=true;
//이런식으로 체크가 되었는지 안되었는지로 확인해야 한다.
//value값으로 확인이 불가하다.

  }  
 }
 if(conf == false){
  alert("안돼");
 }
}
</script>
</head>
<body>
<form name="form">
 <table border="1">
  <tr>
   <td>
    <input type="checkbox" name="sss">1
    <input type="checkbox" name="sss">2
    <input type="checkbox" name="sss">3
   </td>
  </tr>
  
  <tr>
   <td><input type="button" value="check" onClick='sub();'>
   </td>
  </tr>
 </table>
</form>

</body>
</html>


댓글