js  获取单选框的值

这是一个简单的表单示例,用户可以选择性别为男或女。

<input type="radio" name="gender" value="男" checked="checked"/>男  
<input type="radio" name="gender" value="女"/>女


function getSex(){
  var value="";
  var radio=document.getElementsByName("gender");
  for(var i=0;i<radio.length;i++){
        if(radio[i].checked==true){
          value=radio[i].value;
          break;
        }
  }
  return value;
} 
<tr > <td height="35px" width="12.5%" align="right">抽样地点性质:</td> <td width="87.5%" > <label class="i-checks" > 持有人 <input type="radio" name="buffer.fcyddxz" value="持有人" /> </label> <label class="i-checks" style="margin-top: 0px;"> &nbsp;&nbsp;&nbsp;生产单位 <input type="radio" name="buffer.fcyddxz" value="生产单位" /> </label> <label class="i-checks" > &nbsp;&nbsp;&nbsp;配制单位 <input type="radio" name="buffer.fcyddxz" value="配制单位" /> </label> <label class="i-checks" > &nbsp;&nbsp;&nbsp;零售连锁总部 <input type="radio" name="buffer.fcyddxz" value="零售连锁总部" /> </label> <label class="i-checks" style="margin-top: 0px;"> &nbsp;&nbsp;&nbsp;批发<input type="radio" name="buffer.fcyddxz" value="批发" /> </label> <label class="i-checks" style="margin-top: 0px;"> &nbsp;&nbsp;&nbsp;零售药店<input type="radio" name="buffer.fcyddxz" value="零售药店" /> </label> <label class="i-checks" style="margin-top: 0px;"> &nbsp;&nbsp;&nbsp;中药材市场 <input type="radio" name="buffer.fcyddxz" value="中药材市场" /> <label class="i-checks" style="margin-top: 0px;"> &nbsp;&nbsp;&nbsp;医疗机构 <input type="radio" name="buffer.fcyddxz" value="医疗机构" /> <label class="i-checks" style="margin-top: 0px;"> &nbsp;&nbsp;&nbsp;个体诊所 <input type="radio" name="buffer.fcyddxz" value="个体诊所" /> </label> <label class="i-checks" style="margin-top: 0px;"> &nbsp;&nbsp;&nbsp;<input type="radio" name="buffer.fcyddxz" value="其他"/>其他: </label> <input type="text" name="buffer.fcyddxzqt" style="width:150px;" value="${bean.fcyddxzqt }"/> </td> </tr>上述代码每次聚焦到'fcyddxzqt'输入框时,单选框会自动选中'医疗机构'为什么
最新发布
10-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值