日期:2014-05-16 浏览次数:20392 次
<form name='form1' id="form1" method="post"> <table> <tr> <td height="10" style="color:#FF0000 " ><span id='radio_id15'>显示器:</span>:</td> <td height="10" style="color:#FF0000 "> <input type="radio" name="4" value="有" />有<input type="radio" name="4" value="无" />无<input type="radio" name="4" value="未知" />未知</td> <td height="10" style="color:#000000 " ><span id='radio_id16'>鼠标</span>:</td> <td height="10" style="color:#000000 "> <input type="radio" name="7" value="有" />有<input type="radio" name="7" value="无" />无<input type="radio" name="7" value="未知" />未知</td></tr> <tr> <td height="10" style="color:#000000 " ><span id='radio_id17'>椅子</span>:</td> <td height="10" style="color:#000000 "> <input type="radio" name="8" value="有" />有<input type="radio" name="8" value="无" />无<input type="radio" name="8" value="未知" />未知</td> <td height="10" style="color:#000000 " ><span id='radio_id18'>电源</span>:</td> <td height="10" style="color:#000000 "> <input type="radio" name="9" value="有" />有<input type="radio" name="9" value="无" />无<input type="radio" name="9" value="未知" />未知</td></tr> <tr> <td height="10" style="color:#FF0000 "><span id='radio_id19'>网线</span>:</td> <td height="10" style="color:#FF0000 "> <input type="radio" name="10" value="有" />有<input type="radio" name="10" value="无" />无<input type="radio" name="10" value="未知" />未知</td></tr> <tr><td height="40" colspan="4" align="center"><br> <input name="save" type="button" id="btn" value="下一步" onclick="sub()" /> <input name="close" type="reset" value="重新输入" id="btn"/> </td> </tr> </table> </form>
function sub() { var obj = document.getElementsByTagName("input"); //alert(obj.length); -->17 for (var i = 0; i < obj.length; i ++) { var id_value = 'radio_id'+ i; if (obj[i].type == 'radio' && obj[i].checked ==true && obj[i].value =='有') { //alert(id_value); var aid = document.getElementById("'radio_id'+ i"); alert(aid.innerHTML); } } }