<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>
是不是要这样的效果?

解决方案 »

  1.   

    <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>
      

  2.   

    <input type="checkbox" value="a" name="chkb" onclick="if(this.checked){alert('checked')}else{alert('no')}"/>
      

  3.   

    谢谢各位,虽然...用onclick的动作来判断变化有点"面向过程"...不过也算解决,给分.
      

  4.   

    Click the link to solve your problem.Good luck!