Link to home
Start Free TrialLog in
Avatar of Refael
RefaelFlag for United States of America

asked on

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

Avatar of leakim971
leakim971
Flag of Guadeloupe image

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();              
}
Avatar of Refael

ASKER


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?
it only replace the second part, the check_if_checkboxes_checked function
Avatar of Refael

ASKER


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

ASKER CERTIFIED SOLUTION
Avatar of saimazz
saimazz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Refael

ASKER


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!!!
Avatar of Refael

ASKER

read my comment. thank you so much guys!