I'm trying to loop through radio buttons on a form and get their value to compare to another value. If the values are equal it will check the radio button.
The issue I'm having is that the loop only gets the value from the first radio button.
What can I do to have it loop through all the radio buttons?
radio buttons (get appended to the form)
<span class="radioVNC">
<input type="radio" name="EventSet" value="VNC"/>VNC
</span>
<br>
<span class="radioOLV">
<input type="radio" name="EventSet" value="OLV"/>OLV
</span>
<br>
<span class="radioAct">
<input type="radio" name="EventSet" value="Activity"/>Activity
</span>
code
$(document).ready(function () {
var curResType = $('input[title="ReservationType2"]').val();
$('input:radio[name="EventSet"]').each(function () {
var radioVal = $('input[name="EventSet"]').val()
if (radioVal == curResType) {
$(this).prop('checked', true);
}
});
});