<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test029.html</title>
<script type="text/javascript">
function actionChoice()
{
var c=document.getElementsByName("checkboxGroup");
//alert(c.length); ->6
var str="";
var flag=true
for(var i=0; i < c.length; i++)
{
//alert(c[i].checked);
if(c[i].checked)
{
str +=c[i].value+" ";
flag=false;
}
}
if(flag)
{
str="선택한 과목이 없습니다.";
alert(str);
}
else
{
alert(str);
}
}
</script>
</head>
<body>
<div>
<h1>자바스크립트 활용</h1>
<hr>
</div>
<div>
<h2>라디오 버튼 , 체크박스 다루기</h2>
<form >
-----과목 선택------<br><br>
<input type="checkbox" name="checkboxGroup" value="자바기초" id = "a">
<label>java Beginng</label><br>
<input type="checkbox" name="checkboxGroup" value="오라클" id = "b">
<label>Oracle </label><br>
<input type="checkbox" name="checkboxGroup" value="자바심화" id = "c">
<label>Java advanced</label><br>
<input type="checkbox" name="checkboxGroup" value="웹클라이언트" id = "d">
<label>Web Client</label><br>
<input type="checkbox" name="checkboxGroup" value="JSP" id = "e">
<label>JSP/Servlet</label><br>
<input type="checkbox" name="checkboxGroup" value="프레임워크" id = "f">
<label>Framework</label><br>
<br>
<button type="button" onclick ="actionChoice()">확인</button>
</form>
</div>
</body>
</html>