你像通过谁(radio,checkbox)的onclick事件获取?

解决方案 »

  1.   

    <script language=javascript>
    function a123()
    {
    for(i=0;i<document.all.a1.length;i++)
    {
    if(document.all.a1[i].checked)
    {
    alert(document.all.a1[i].value)
    }
    }
    for(i=0;i<document.all.b1.length;i++)
    {
    if(document.all.b1[i].checked)
    {
    alert(document.all.b1[i].value)
    }
    }
    }
    </script>
    <input name=a1 type=radio checked value=1>
    <input name=a1 type=radio value=2>
    <input name=a1 type=radio value=3>
    <input name=a1 type=radio value=4>
    <input name=a1 type=radio value=5>
    <input name=a1 type=radio value=6>
    <input name=b1 type=checkbox  value=1>
    <input name=b1 type=checkbox value=2>
    <input name=b1 type=checkbox value=3>
    <input name=b1 type=checkbox value=4>
    <input name=b1 type=checkbox value=5>
    <input name=c1 type=button onclick=a123() value="得到值">
    测试过,可以的
      

  2.   

    我是通过单击radio来显示出checkbox和raido的值:
    html-----------------
    <table>
    <tr>
    <td>
    <input type="radio" name="rad1" value="r1" onclick="fncChecked()">
    <input type="radio" name="rad1" value="r2" onclick="fncChecked()">
    <input type="radio" name="rad1" value="r3" onclick="fncChecked()">
    <input type="radio" name="rad1" value="r4" onclick="fncChecked()">
    <input type="radio" name="rad1" value="r5" onclick="fncChecked()">
    </td>
    <td>
    <input type="checkbox" name="che1" value="c1">
    <input type="checkbox" name="che1" value="c2">
    <input type="checkbox" name="che1" value="c3">
    <input type="checkbox" name="che1" value="c4">
    <input type="checkbox" name="che1" value="c5">
    </td>
    </tr>
    </table>
    javascript-------------------
    function fncChecked()
    {
    var rads=document.MyForm.rad1.length;
    var ches=document.MyForm.che1.length;
    var temp="";
    for(i=0;i<rads;i++)
    {
    if(document.MyForm.rad1[i].checked)
    {
    temp=temp+"radio:"+document.MyForm.rad1[i].value+";";
    for(j=0;j<rads;j++)
    {
    if(document.MyForm.che1[j].checked)
    {
    temp=temp+"checkbox:"+document.MyForm.che1[j].value+",";
    }
    }

    }
    alert(temp);
    }
      

  3.   

    andymu077(明治佐玛戒--秀曼)
    可用