<form name='form1' id="form1" method="post">
<table width="90%"  border="0" align="center" >  
  <tr>
   <td height="10" style="color:#FF0000 " >显示器:</td>
<td height="10" style="color:#FF0000 ">
<input type="radio" name="6" value="有"  onChange="change()" >有<input type="radio" name="6" value="无" onChange="change()" checked>无<input type="radio" name="6" value="未知"  onChange="change()" >未知</td>
<td height="10" style="color:#000000 " >鼠标:</td>
<td height="10" style="color:#000000 ">
<input type="radio" name="3" value="有"  onChange="change()" >有<input type="radio" name="3" value="无" onChange="change()" checked>无<input type="radio" name="3" value="未知"  onChange="change()" >未知</td></tr>
<tr>
<td height="10" style="color:#FF0000 " >键盘:</td>
<td height="10" style="color:#FF0000 ">
<input type="radio" name="4" value="有"  onChange="change()" >有<input type="radio" name="4" value="无" onChange="change()" checked>无<input type="radio" name="4" value="未知"  onChange="change()" >未知</td>
<td height="10" style="color:#000000 " >椅子:</td>
<td height="10" style="color:#000000 ">
<input type="radio" name="7" value="有"  onChange="change()" >有<input type="radio" name="7" value="无" onChange="change()" checked>无<input type="radio" name="7" value="未知"  onChange="change()" >未知</td></tr>
<tr>
<td height="10" style="color:#000000 " >电源:</td>
<td height="10" style="color:#000000 ">
<input type="radio" name="8" value="有"  onChange="change()" >有<input type="radio" name="8" value="无" onChange="change()" checked>无<input type="radio" name="8" value="未知"  onChange="change()" >未知</td>
<td height="10" style="color:#000000 " >鼻息肉:</td>
<td height="10" style="color:#000000 ">
<input type="radio" name="9" value="有"  onChange="change()" >有<input type="radio" name="9" value="无" onChange="change()" checked>无<input type="radio" name="9" value="未知"  onChange="change()" >未知</td></tr>
<tr>
<td height="10" style="color:#FF0000 " >网络:</td>
<td height="10" style="color:#FF0000 ">
<input type="radio" name="10" value="有"  onChange="change()" >有<input type="radio" name="10" value="无" onChange="change()" checked>无<input type="radio" name="10" value="未知"  onChange="change()" >未知</td></tr>
<tr><td height="40" colspan="4"  align="center"><br>
    <input name="test" type="button"  id="btn"  value="下一步"  onclick="test();" > 
<input name="close" type="reset"  value="重新输入"  id="btn">
   </td> </tr>
</table>
</form>
<script type="text/javascript">
function test() {
var ar_text = [], ar_radio = [], i = 0;
var obj = document.getElementsByTagName("input"); //貌似是这行有问题
for (var i = 0; i < obj.length; i ++) {
if (obj[i].type == 'radio' && obj[i].value =='有')
{
ar_radio.push(obj[i].value);
}

}
alert(ar_radio);
}
</script>

解决方案 »

  1.   


    if (obj[i].type == 'radio' && obj[i].value =='有')以前是
    if (obj[i].type == 'radio' && obj[i].check==true)为啥过滤不了 点无的呢ar_radio 数组只要点 有的 
      

  2.   


    <form name='form1' id="form1" method="post">
    <table width="90%"  border="0" align="center" >  
      <tr>
          <td height="10" style="color:#FF0000 " >显示器:</td>
        <td height="10" style="color:#FF0000 ">
            <input type="radio" name="6" value="有"  onChange="change()" >有<input type="radio" name="6" value="无" onChange="change()" checked>无<input type="radio" name="6" value="未知"  onChange="change()" >未知</td>
        <td height="10" style="color:#000000 " >鼠标:</td>
        <td height="10" style="color:#000000 ">
            <input type="radio" name="3" value="有"  onChange="change()" >有<input type="radio" name="3" value="无" onChange="change()" checked>无<input type="radio" name="3" value="未知"  onChange="change()" >未知</td></tr>
    <tr>
        <td height="10" style="color:#FF0000 " >键盘:</td>
        <td height="10" style="color:#FF0000 ">
            <input type="radio" name="4" value="有"  onChange="change()" >有<input type="radio" name="4" value="无" onChange="change()" checked>无<input type="radio" name="4" value="未知"  onChange="change()" >未知</td>
        <td height="10" style="color:#000000 " >椅子:</td>
        <td height="10" style="color:#000000 ">
            <input type="radio" name="7" value="有"  onChange="change()" >有<input type="radio" name="7" value="无" onChange="change()" checked>无<input type="radio" name="7" value="未知"  onChange="change()" >未知</td></tr>
    <tr>
        <td height="10" style="color:#000000 " >电源:</td>
        <td height="10" style="color:#000000 ">
            <input type="radio" name="8" value="有"  onChange="change()" >有<input type="radio" name="8" value="无" onChange="change()" checked>无<input type="radio" name="8" value="未知"  onChange="change()" >未知</td>
        <td height="10" style="color:#000000 " >鼻息肉:</td>
        <td height="10" style="color:#000000 ">
            <input type="radio" name="9" value="有"  onChange="change()" >有<input type="radio" name="9" value="无" onChange="change()" checked>无<input type="radio" name="9" value="未知"  onChange="change()" >未知</td></tr>
    <tr>
        <td height="10" style="color:#FF0000 " >网络:</td>
        <td height="10" style="color:#FF0000 ">
            <input type="radio" name="10" value="有"  onChange="change()" >有<input type="radio" name="10" value="无" onChange="change()" checked>无<input type="radio" name="10" value="未知"  onChange="change()" >未知</td></tr>
    <tr><td height="40" colspan="4"  align="center"><br>
        <input name="test" type="button"  id="btn"  value="下一步"  onclick="fn()" > 
        <input name="close" type="reset"  value="重新输入"  id="btn">
       </td> </tr>
    </table>
    </form>
    <script type="text/javascript">
        function fn(){
            var ar_text = [], ar_radio = [], i = 0;
            var obj = document.getElementsByTagName("input"); //貌似是这行有问题
            for (var i = 0; i < obj.length; i ++) {
                if (obj[i].type == 'radio' && obj[i].value =='有')
                {
                    ar_radio.push(obj[i].value);
                    }
                    
            }
            alert(ar_radio);
        }
    </script>
      

  3.   


    <form name='form1' id="form1" method="post">
    <table width="90%"  border="0" align="center" >  
      <tr>
          <td height="10" style="color:#FF0000 " >显示器:</td>
        <td height="10" style="color:#FF0000 ">
            <input type="radio" name="6" value="有"  onChange="change()" >有<input type="radio" name="6" value="无" onChange="change()" checked>无<input type="radio" name="6" value="未知"  onChange="change()" >未知</td>
        <td height="10" style="color:#000000 " >鼠标:</td>
        <td height="10" style="color:#000000 ">
            <input type="radio" name="3" value="有"  onChange="change()" >有<input type="radio" name="3" value="无" onChange="change()" checked>无<input type="radio" name="3" value="未知"  onChange="change()" >未知</td></tr>
    <tr>
        <td height="10" style="color:#FF0000 " >键盘:</td>
        <td height="10" style="color:#FF0000 ">
            <input type="radio" name="4" value="有"  onChange="change()" >有<input type="radio" name="4" value="无" onChange="change()" checked>无<input type="radio" name="4" value="未知"  onChange="change()" >未知</td>
        <td height="10" style="color:#000000 " >椅子:</td>
        <td height="10" style="color:#000000 ">
            <input type="radio" name="7" value="有"  onChange="change()" >有<input type="radio" name="7" value="无" onChange="change()" checked>无<input type="radio" name="7" value="未知"  onChange="change()" >未知</td></tr>
    <tr>
        <td height="10" style="color:#000000 " >电源:</td>
        <td height="10" style="color:#000000 ">
            <input type="radio" name="8" value="有"  onChange="change()" >有<input type="radio" name="8" value="无" onChange="change()" checked>无<input type="radio" name="8" value="未知"  onChange="change()" >未知</td>
        <td height="10" style="color:#000000 " >鼻息肉:</td>
        <td height="10" style="color:#000000 ">
            <input type="radio" name="9" value="有"  onChange="change()" >有<input type="radio" name="9" value="无" onChange="change()" checked>无<input type="radio" name="9" value="未知"  onChange="change()" >未知</td></tr>
    <tr>
        <td height="10" style="color:#FF0000 " >网络:</td>
        <td height="10" style="color:#FF0000 ">
            <input type="radio" name="10" value="有"  onChange="change()" >有<input type="radio" name="10" value="无" onChange="change()" checked>无<input type="radio" name="10" value="未知"  onChange="change()" >未知</td></tr>
    <tr><td height="40" colspan="4"  align="center"><br>
        <input name="test" type="button"  id="btn"  value="下一步"  onclick="fn()" > 
        <input name="close" type="reset"  value="重新输入"  id="btn">
       </td> </tr>
    </table>
    </form>
    <script type="text/javascript">
        function fn(){
            var ar_text = [], ar_radio = [], i = 0;
            var obj = document.getElementsByTagName("input"); //貌似是这行有问题
            for (var i = 0; i < obj.length; i ++) {
    console.log( obj[i].value )
                if (obj[i].type == 'radio' && obj[i].value =='有' && obj[i].checked)
                {
                    ar_radio.push(obj[i].value);
                    }
                    
            }
            alert(ar_radio);
        }
    </script>楼主 这个意思?