相关疑难解决方法(0)

jQuery获取所选单选按钮的值

问题陈述很简单.我需要查看用户是否从广播组中选择了一个单选按钮.组中的每个单选按钮共享相同的ID.

问题是我无法控制表单的生成方式.以下是单选按钮控件代码的示例代码:

<input type="radio" name='s_2_1_6_0' value='Mail copy to my bill to address' id = "InvCopyRadio" onchange = 'SWESubmitForm(document.SWEForm2_0,s_4,"","1-DPWJJF")' style="height:20;width:25" tabindex=1997 >
Run Code Online (Sandbox Code Playgroud)

除此之外,当选择单选按钮时,它不会向控件添加"已选中"属性,只是选中 了文本(我猜测只检查了没有值的属性).以下是所选无线电控制的外观

<input type="radio" checked name='s_2_1_6_0' value='Mail copy to my bill to address' id = "InvCopyRadio" onchange = 'SWESubmitForm(document.SWEForm2_0,s_4,"","1-DPWJJF")' style="height:20;width:25" tabindex=1997 >
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我使用jQuery代码,可以帮助我获得已检查单选按钮的值吗?

jquery siebel radio-button

507
推荐指数
20
解决办法
106万
查看次数

在jQuery中,当它们都具有相同的名称时,如何获得单选按钮的值?

这是我的代码:

<table>
   <tr>
      <td>Sales Promotion</td>
      <td><input type="radio" name="q12_3" value="1">1</td>
      <td><input type="radio" name="q12_3" value="2">2</td>
      <td><input type="radio" name="q12_3" value="3">3</td>
      <td><input type="radio" name="q12_3" value="4">4</td>
      <td><input type="radio" name="q12_3" value="5">5</td>
   </tr>
</table>
<button id="submit">submit</button>
Run Code Online (Sandbox Code Playgroud)

这是JS:

$(function(){
    $("#submit").click(function(){      
        alert($('input[name=q12_3]').val());
    });
 });
Run Code Online (Sandbox Code Playgroud)

这是JSFIDDLE!每次我点击按钮它都会返回1.为什么?谁能帮我?

javascript jquery

108
推荐指数
4
解决办法
27万
查看次数

标签 统计

jquery ×2

javascript ×1

radio-button ×1

siebel ×1