<html>
<body>
<form name="sample">
<tbody>
<tr>
<th>question</th>
</tr>
<tr>
<td>
<input type="checkbox" value="a" name="chkb" onclick="selectChange(0);"/>a
<input type="checkbox" value="b" name="chkb" onclick="selectChange(1);"/>b
<input type="checkbox" value="c" name="chkb" onclick="selectChange(2);"/>c
</td>
</tr>
</tbody>
</form>
<script>
function selectChange(num)
{
if (document.sample.chkb[num].checked==true)
{
alert('check')
}
else{
alert('undef')
}
}
</script>
</body>
</html>
是不是要这样的效果?
<body>
<form name="sample">
<tbody>
<tr>
<th>question</th>
</tr>
<tr>
<td>
<input type="checkbox" value="a" name="chkb" onclick="selectChange(0);"/>a
<input type="checkbox" value="b" name="chkb" onclick="selectChange(1);"/>b
<input type="checkbox" value="c" name="chkb" onclick="selectChange(2);"/>c
</td>
</tr>
</tbody>
</form>
<script>
function selectChange(num)
{
if (document.sample.chkb[num].checked==true)
{
alert('check')
}
else{
alert('undef')
}
}
</script>
</body>
</html>
是不是要这样的效果?
<body>
<form name="sample">
<tbody>
<tr>
<th>question</th>
</tr>
<tr>
<td>
<input type="checkbox" value="a" name="chkb" onclick="javascript:cbchecked(0);" />a
<input type="checkbox" value="b" name="chkb" onclick="javascript:cbchecked(1);" />b
<input type="checkbox" value="c" name="chkb" onclick="javascript:cbchecked(2);" />c
</td>
</tr>
</tbody>
</form>
<script>
function cbchecked(str){
if (document.sample.chkb[str].checked==true)
{
alert('check')
}
else{
alert('undef')
}
}
</script>
</body>
</html>