jquery check-boxes

Hello Experts,

I got the solution below from sonawanekiran (an experts-exchange expert :-)).
i changed it a bit but it does not seem to work anymore. I was doing testings but nothing get it to work. can you please help?

* there are two check-boxes to check ... if both are checked then print the note.
$(document).ready(function() {
$(".checkboxes").click(function(){
  check_if_checkboxes_checked();
  });	
}); 

function check_if_checkboxes_checked(){
var flag = true;
$(".checkboxes").each(function(){
if (!$(this).is(':checked')) 
flag = false;
});
if (flag) {
$('#additionalNote').append('<span class="tbl_note">Please note: $10 will be added to the monthly payment.</span>');
}
else
$('#additionalNote span').remove();               
}

Open in new window

RefaelAsked:
Who is Participating?
 
saimazzCommented:
$(function() {
$(".checkboxes").click(function(){
    check_if_checkboxes_checked();
     });
 });

 function check_if_checkboxes_checked(){
   if($(".checkboxes:checked").size() == 2) {
        $('#additionalNote').append('<span class="tbl_note">Please note: $10 will be added to the monthly payment.</span>');
        return true;
	}
  $('#additionalNote span').remove()
}

Open in new window

checkbox-sample.html
0
 
leakim971PluritechnicianCommented:
function check_if_checkboxes_checked(){
   if($(".checkboxes:checked").length < 2)
        $('#additionalNote').append('<span class="tbl_note">Please note: $10 will be added to the monthly payment.</span>');
        return true;
   }
   $('#additionalNote span').remove();              
}
0
 
RefaelAuthor Commented:

Hi leakim971,


no, it does not work.
i guess the above replace my script, right? and this code above should be in the "$(document).ready(function() {" and not after?
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
leakim971PluritechnicianCommented:
it only replace the second part, the check_if_checkboxes_checked function
0
 
RefaelAuthor Commented:

leakim971,

first there is an error ( i have to remove the last '}' to get rid of the error.
second it does not work. here is the entire script.

$(document).ready(function() {
$(".checkboxes").click(function(){
    check_if_checkboxes_checked();
     });
 });

 function check_if_checkboxes_checked(){
   if($(".checkboxes:checked").length < 2)
        $('#additionalNote').append('<span class="tbl_note">Please note: $10 will be added to the monthly payment.</span>');
        return true;
	}
  $('#additionalNote span').remove()
}

Open in new window

0
 
leakim971PluritechnicianCommented:
Corrected (missing brace line 8):

$(document).ready(function() {
    $(".checkboxes").click(function(){
        check_if_checkboxes_checked();
    });
});

function check_if_checkboxes_checked() {
    if($(".checkboxes:checked").length < 2) {
        $('#additionalNote').append('<span class="tbl_note">Please note: $10 will be added to the monthly payment.</span>');
        return true;
    }
    $('#additionalNote span').remove()
}

Open in new window

0
 
RefaelAuthor Commented:

Guys. i am so so so sorry!
the problem was a misspelling of the class name 'checkboxs" instead of "checkboxes"... how duff  am i?
i am sorry i was bothering you..... thanks. both of the solution works just fine!!!
0
 
RefaelAuthor Commented:
read my comment. thank you so much guys!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.