Reputation: 99
I have 2 sets of radio buttons called 'attendance1' and 'attendace2'. When I click YES for attendance1 it asks please select attendance for USER2 and removes attendance1 for user1. How do I PREVENT THIS?
$(function(){
$("#att").click(function() {
if (!$("input[name=attendance1]").is(":checked")) {
alert('Please select attendance for <?php echo $row3['name1']?>');
return false;
}
if (!$("input[name=attendance2]").is(":checked")) {
alert('Please select attendance for <?php echo $row3['name2']?>');
return false;
}
});
});
Upvotes: 0
Views: 70
Reputation: 5249
Your code looks fine to me. Do you have a link we can look at?
You might try changing your if
and to else if
:
$(function(){
$("#att").click(function() {
if (!$("input[name=attendance1]").is(":checked")) {
alert('Please select attendance for <?php echo $row3['name1']?>');
return false;
}else if (!$("input[name=attendance2]").is(":checked")) {
alert('Please select attendance for <?php echo $row3['name2']?>');
return false;
}
});
});
Upvotes: 1