Get RadioButtonList selected value by jQuery/JavaScript
How to get radio button list selected value from a list of radio buttons by using either jQuery or JavaScript
<asp:RadioButtonList ID="rbtnCardType" runat="server">
<asp:ListItem Value="1" Text="Visa" />
<asp:ListItem Value="2" Text="Master" />
<asp:ListItem Value="3" Text="Maestro" />
</asp:RadioButtonList>
3 Answers
Simply you can use
$("#<%= rbtnCardType.ClientID %> input:checked").val();
|
2
|
Answered:
06 Mar 2013
Reputation: 1,880
|
|
use on click even on radio button list and get all input types and try to get selected value by using for loop
<asp:RadioButtonList ID="rbtnCardType" runat="server" onclick="CardChanged(this)">
<asp:ListItem Value="1" Text="Visa" />
<asp:ListItem Value="2" Text="Master" />
<asp:ListItem Value="3" Text="Maestro" />
</asp:RadioButtonList>
function CardChanged(rbtn){
var radios = rbtn.getElementsByTagName("input");
for (var i = 0; i < radios.length; i++)
if (radios[i].checked)
return radios[i].value;
}
|
1
|
Answered:
06 Mar 2013
Reputation: 1,109
|
|
you can also use this
$('#<%=rbtnCardType.ClientID %> input[type=radio]:checked').val();
|
0
|
Answered:
06 Mar 2013
Reputation: 242
|
|
This week users
