Reputation: 4023
I have the following block in my HTML
<div class="selection">
<p><input name="custrecord_npsdtl_decision" id="custrecord_npsdtl_decision" type="radio" value="I am solely responsible for the decision">I am solely responsible for the decision </p>
<p><input name="custrecord_npsdtl_decision" id="custrecord_npsdtl_decision" type="radio" value="I am partially responsible for or influence the decision">I am partially responsible for or influence the decision </p>
<p><input name="custrecord_npsdtl_decision" id="custrecord_npsdtl_decision" type="radio" value="I am not involved in the decision">I am not involved in the decision </p>
<p><input name="custrecord_npsdtl_decision" id="custrecord_npsdtl_decision" type="radio" value="Don't know">Don't know </p>
</div>
And a function to check form-progression, based on the option selected, with the following snippet:
var decisionmaker = $('#custrecord_npsdtl_decision:checked').val();
if (decisionmaker == elements['customlist_nps_decision'][2] || decisionmaker == elements['customlist_nps_decision'][3]) {
redirect();
}
This works as expected in Chrome, Firefox but was not working in Internet Explorer(8). Doing some inspection I found that
$('#custrecord_npsdtl_decision:checked')
returns an object, as expected, but calling val() on the object returns undefined.
I am absolutely bewildered. How do I get the selected option from the radio list in IE?
Upvotes: 2
Views: 2469
Reputation: 3091
you shouldnt use the same ID for each radio button and you can use the name selector to get the group selection
$('input[name=custrecord_npsdtl_decision]:checked').val();
Upvotes: 2
Reputation: 95023
ID's must be unique. I'm very surprised that this is working at all in Chrome and Firefox.
Remove the id attributes and select by name.
$('input[name="custrecord_npsdtl_decision"]:checked').val();
Upvotes: 5