i have the following jquery code which checks radio buttons and hide or show the associated warning box when none of the radio buttons are selected in each group.
However when i run the code, it takes values of the first checked radio and assigned it to all values of radio buttons (even if they are not selected).
so when i select only the 8th group of radio buttons with a value of 4, in the console i get
6 is checked: 4
7 is checked: 4
8 is checked: 4
but it should print
oh no
oh no
8 is checked: 4
can you help me about this issue?
Thanks.
$.each(checkboxers, function(_, q)
{
var warnbox = $('.q' + q);
if (!!$("input[@name='answer" + q + "']:checked").val()) {
console.log(q + ' is checked.' + $("input[@name='answer" + q + "']:checked").val());
warnbox.hide();
} else {
console.log('oh no!');
err = true;
warnbox.show();
}
});
Removed all the @ s and problem solved..