<html>
<head>
<title>Example</title>
</head>
<body>
<div>
<input type="checkbox" name="a" value="1" />
<input type="checkbox" name="b" value="2" />
<input type="checkbox" name="c" value="3" />
</div>
<script type="text/javascript">
var inputs = document.getElementsByTagName("input"); //or document.forms[0].elements;
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == 'checkbox') {
inputs[i].onclick=function() { alert('A checkbox value was changed');
}
}
}
</script>
</body>
</html>
|