Reputation: 1632
I have group radio buttons with same name cost and different id's cost_1, cost_2. and their values are also different. I wish to collect value of selected radio button. and show it in particular text box that is 'total' including values of other radio button group. How can I get value of selected radio button from name using jQuery? Because if I select it using ID and loop it will count value of each radio button.
Upvotes: 1
Views: 306
Reputation: 22007
You could filter for the name and the checked status:
$('input[type="radio"][name="cost"]:checked').val()
Edit: got the selector wrong, now it should work.
Upvotes: 1