- $(':checkbox').on('change', function(event){
- if(this.checked) {
- $(this).val(1);
- var id = $(this).attr('id');
- $("."+id).remove();
- }else{
- var name = $(this).attr('name');
- var cls = $(this).attr('id');
- $(this).after( "<input type='hidden' name='"+name+"' class='"+cls+"' value='0'/>" );
- }
- });
checkbox value check and uncheck in php and storing in Mysql database
ReplyDeleteThe 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.