<script>
function aa()
{
l=document.getElementsByName("sex")
for(i=0;i<l.length;i++)
{
if(l[i].checked) alert(l[i].value)
}
}
</script>
<input type=radio value="1" selected name=sex>男
<input type=radio value="0" name=sex>女
<input type=button onclick="aa()">

解决方案 »

  1.   

    <input name=r type=radio value=1><input name=r type=radio value=2><input name=r  type=radio value=3><input type=submit onclick="for(i=0;i<r.length;i++)alert(r[i].value)">
      

  2.   

    <input type=radio value="1" checked name=sex>男
    <input type=radio value="0" name=sex>女
    <input type=button onclick="for(var i=0;i<sex.length;i++){if(sex[i].checked)alert('your select:'+sex[i].value)}">
      

  3.   

    <input type=radio value="1" checked name=sex>男
    <input type=radio value="0" name=sex>女
    <input type=button onclick="for(i=0;i<sex.length;i++){if(sex[i].checked)alert(sex[i].value)}" value=sumit></body>
      

  4.   

    <input type=radio value="1" checked name=sex>男
    <input type=radio value="0" name=sex>女
    <input type=button onclick="for(i=0;i<sex.length;i++){if(sex[i].checked)alert(sex[i].value)}" value=sumit>
      

  5.   

    <input type=radio value="1" checked name=sex>男
    <input type=radio value="0" name=sex>女
    <input type=button onclick="for(i=0;i<sex.length;i++){if(sex[i].checked)alert(sex[i].value)}" value=submit>
      

  6.   

    <input type=radio value="1" selected name=sex>男
    <input type=radio value="0" name=sex>女
    <input type=button onclick="javascript:alert(sex.value)">