Reputation: 83
I have a group of radio group like below and I am having problems getting the selected/checked value. I think is it because the name is an array. I renamed my id's to the same to see if I could do it that way but no luck.
<input type="radio" name="accounts[1][details][status]" value="1" id="status_1" />
<input type="radio" name="accounts[1][details][status]" value="2" id="status_1" />
Thanks
Upvotes: 3
Views: 8300
Reputation: 9206
This should do it. See jQuery docs on escaping special characters.
$('input[name="accounts\\[1\\]\\[details\\]\\[status\\]"]:checked').val();
Upvotes: 7
Reputation: 5198
You're looking for :checked to get the one that is selected
<input type="radio" name="accounts[1][details][status]" value="1" class="status" />
<input type="radio" name="accounts[1][details][status]" value="2" class="status" />
jQuery:
$(".status").change(function ()
{
var checked_value = $(".status:checked").val();
});
Upvotes: 4