Thursday, 29 September 2016

  1. $(':checkbox').on('change', function(event){
  2.      if(this.checked) {
  3.       $(this).val(1);
  4.         var id = $(this).attr('id');
  5.         $("."+id).remove();
  6.                 }else{
  7.       var name = $(this).attr('name');
  8.        var cls = $(this).attr('id');
  9.        $(this).after( "<input type='hidden' name='"+name+"' class='"+cls+"' value='0'/>" );
  10.                 } 
  11.       });

1 comment:

  1. checkbox value check and uncheck in php and storing in Mysql database
    The checkbox value will be submitted as 1 in php and saved to database with value 1.

    If you want to change this value as 0 and post the value in php it will not be posted onsubmit.

    So We can Use jquery to do this for saving the checkbox value of 1 as 0 in database.

    ReplyDelete