라디오 버튼 체크여부 확인 > script

본문 바로가기
사이트 내 전체검색

script

라디오 버튼 체크여부 확인

페이지 정보

작성자 서방님 댓글 0건 조회 176회 작성일 07-08-08 10:21

본문

<script language="javascript">
<!--
  var count = 0;
  var num=frm.user_ing.length

  for(i=0; i<num; i++)
  {
   if(frm.user_ing[i].checked == true)
   {
   count +=1;
   }
  }
   if(count==0)
   {
   alert("선택해 주세요.");
   return;
   }

//-->
</script>


===============================

<script>
function checkRadioButton(objName){
var radioObj = document.all(objName);
var isChecked;
if(radioObj.length == null){ // 라디오버튼이 같은 name 으로 하나밖에 없다면
isChecked = radioObj.checked;
}else{ // 라디오 버튼이 같은 name 으로 여러개 있다면
for(i=0; i<radioObj.length; i++){
if(radioObj[i].checked){
isChecked = true;
break;
}
}
}

if(isChecked)
alert('체크된거있음');
else
alert('체크된거없음');
}
</script>

<form name=form>
결혼여부
<input type="radio" name="comm_stat_flag" value="10">기혼
<input type="radio" name="comm_stat_flag" value="20">미혼
<input type=button value="라디오버튼 체크여부확인" onClick="checkRadioButton('comm_stat_flag')">


======================================

<script language="javascript">
<!--
function checkRadio(form) {
        for(var i=0;i<form.radio1.length;        i++) { // 라디오버튼의 갯수-1 만큼 루프를 돌립니다
                if (form.radio1[i].checked == true) { // 체크된 버튼을 찾으면
                alert(i+1+" 번째 버튼이 체크되었습니다"); // 메세지를 출력합니다
                return;
                }
        }
        if(i==form.radio1.length) {
        // 체크된 숫자가 라디오버튼의 갯수와 같으면
        // (이 예제에서 라디오버튼의 갯수는 5개 이지만,
        // 배열에서 5번째 라디오버튼은 radio1[4] 가 됩니다)
        // 즉, 체크된 숫자가 radio1[5] 이면 아무것도 선택하지 않았다는 말이므로
                alert("한가지를 선택해 주세요") // 메세지를 출력합니다
                return;
        }
}
//-->
</script>

</head>

<body>

<form name="form1" method=post>
채널1 <input type="radio" name="radio1">
채널2 <input type="radio" name="radio1">
채널3 <input type="radio" name="radio1">
채널4 <input type="radio" name="radio1">
채널5 <input type="radio" name="radio1">
<input type="button" value=" 확인 "  onclick="checkRadio(this.form)">
</form>

댓글목록

등록된 댓글이 없습니다.

Total 846건 41 페이지
게시물 검색

회원로그인

접속자집계

오늘
21
어제
302
최대
1,347
전체
155,082
Latest Crypto Fear & Greed Index

그누보드5
Copyright © 서방님.kr All rights reserved.