当前位置: 代码迷 >> JavaScript >> js radio checked 取值的有关问题
  详细解决方案

js radio checked 取值的有关问题

热度:412   发布时间:2012-10-08 19:54:56.0
js radio checked 取值的问题

如看原码

 <tr>
        <td align="right"><b>学历:</b></td>
        <td>
        	 <input tabindex="7" type="radio" name="schoolRecord" id="schoolRecord"   value="1" <s:if test="teacherInfo.schoolRecord==1"> checked="checked" </s:if> />高中(包括:高中,职高,中专,技校)
        	 <input tabindex="8" type="radio" name="schoolRecord" id="schoolRecord" value="2"  <s:if test="teacherInfo.schoolRecord==2"> checked="checked" </s:if> />大专
        	  <input tabindex="9" type="radio" name="schoolRecord" id="schoolRecord" value="3"  <s:if test="teacherInfo.schoolRecord==3"> checked="checked" </s:if>/>本科
        	  <input tabindex="10" type="radio" name="schoolRecord" id="schoolRecord" value="4" <s:if test="teacherInfo.schoolRecord==4"> checked="checked" </s:if>/>研究生(包括硕士,博士)
        	  <input tabindex="11" type="radio" name="schoolRecord" id="schoolRecord" value="0" <s:if test="teacherInfo.schoolRecord==0"> checked="checked" </s:if> />其他的
        	  
        
        </tr>

? js

   function select_value(str)
      {
      		      var   obj   =   document.getElementsByName(""+str);
						var   obj_value;
						  for   (var   i=0;   i   <   obj.length;   i++)
 							 {
 							    if   (obj[i].checked)
     					          obj_value   =   obj[i].value; 
     					       }
     					 return obj_value;
      }
alert(select_value("schoolRecord"))

??

  相关解决方案