For this we need basic jquery library file. I am using onclick bind function to process this event you can do it with manual function also by calling on clcik of any button or anchor.
Her is xample:-
We have basic form
<form id=”simpleFormId” name=”simpleFormName” method=”post” enctype=”multipart/form-data” autocomplete=”off” >
<input type=”checkbox” id=”student_delete_chk_all” name=”student_delete_chk_all”>
<input type=”checkbox” id=”it-table52″ class=”student_delete” value=”52″ name=”student_delete[]”>
<input type=”checkbox” id=”it-table126″ class=”student_delete” value=”126″ name=”student_delete[]”>
<input type=”checkbox” id=”it-table53″ class=”student_delete” value=”53″ name=”student_delete[]”>
</form>
now on script i am creating a onclick function based on id of master check box which i am assuming is “student_delete_chk_all”.
Here what i am doing first checking is master checkbox is checked or not on basis of that applying same attribute or property on all child checkboxes. variable “checkedValue” have property of master checkbox.
<script>
$(“#student_delete_chk_all”).click( function(){
var checkedValue = $(this).prop(“checked”);
$(“input.student_delete”).prop(“checked”, checkedValue);
});
</script>
My function is class based but you can modified it according to your understanding or requirment.
- Jquery webcam plugin - June 19, 2016
- How To Add and Delete Users on a CentOSServer - June 5, 2016
- How To Set Up vsftpd on CentOS 6 - June 5, 2016