通过javascript获取asp单选按钮值

通过javascript获取asp单选按钮值,javascript,asp.net,Javascript,Asp.net,我在谷歌上搜索,通过javascript获取asp radiobutton的值,但我一直没有定义。我寻找了几乎所有的方法来获得rb值,但确定了为什么我没有定义。感谢您的帮助 单击对话框窗口的“确定”按钮时,将调用clientfunction() 这是我的密码 函数clientFunction(){ 调试器; $('select[id$=rbThisButton]')。每个(函数(){ var val=该值; 如果(val='All'){flag=true;} }); var test=$('#

我在谷歌上搜索,通过javascript获取asp radiobutton的值,但我一直没有定义。我寻找了几乎所有的方法来获得rb值,但确定了为什么我没有定义。感谢您的帮助

单击对话框窗口的“确定”按钮时,将调用clientfunction()

这是我的密码


函数clientFunction(){
调试器;
$('select[id$=rbThisButton]')。每个(函数(){
var val=该值;
如果(val='All'){flag=true;}
});
var test=$('#input[type=radio]:checked').val();
var selectedVal=$(“[id$='rbThisButton']”)。查找(“:选中”).val();
var selectedvalue=$(“#输入:选中”).val()
调试器;
var rates=document.getElementById('rbThisButton');
}   

如果您想知道是否选中了单选按钮,只需执行以下操作:

var isChecked = $('#<%=rbThisButton.ClientID %>').is(":checked");
var isChecked=$('#')。是(“:checked”);

要分析您的尝试不起作用的原因,请执行以下操作:

$('select[id$=rbThisButton]')
//This is looking for a SELECT (DropDownList), not an input

$('#<%=rbThisButton.ClientID %> input[type=radio]:checked')
$("[id$='rbThisButton']").find(":checked")
$('#<%= rbThisButton.ClientID %> input:checked')
//Both a space in a selector and the .find() function are looking for CHILDREN
//so you're not finding anything with these - your radio button has no children
$('select[id$=rbThisButton]”)
//这是在寻找一个SELECT(DropDownList),而不是一个输入
$('#输入[类型=无线电]:选中')
$(“[id$='rbThisButton']”。查找(“:选中”)
$(“#输入:选中”)
//选择器中的空格和.find()函数都在查找子项
//所以你找不到这些东西-你的单选按钮没有孩子

何时调用
clientFunction
客户端函数?单击“确定”按钮时调用clientFunction。一个
asp:radiobutton
生成一个
,那么为什么您要尝试选择:
选择[id$=rbThisButton]
而不是
输入[type=radio][id*=rbThisButton]
您不需要检查
:已检查
,因为该组中的所有单选按钮将/应该具有相同的名称。您只需查看带有所用内容的
名称的单选按钮的值。
$('select[id$=rbThisButton]')
//This is looking for a SELECT (DropDownList), not an input

$('#<%=rbThisButton.ClientID %> input[type=radio]:checked')
$("[id$='rbThisButton']").find(":checked")
$('#<%= rbThisButton.ClientID %> input:checked')
//Both a space in a selector and the .find() function are looking for CHILDREN
//so you're not finding anything with these - your radio button has no children