How to check all checkbox or multiple checkbox by clicking one checkbox using Jquery?

In this Example, I am using jquery for selecting or checking multiple checkbox by single click on checkbox.
first of all download the JQuery that is most important to perform this task in our project. so remember that download JQuery into your system. don't allow JQuery to direct access from the internet otherwise it will not run in your project. just make separate folder named JS and put JQuery into it.

Note: - Keep jquery file into a folder named JS then give that path into the file.

After that simply copy the given code and paste into your file.


<script src="js/jquery.min.js"></script>       // JS is the path for JQuery file
<script>
function checkall() {
var All_Days = $("#check_all").is(":checked") ? "true" : "false";
    if(All_Days=='true')
    {
        $('.clsborder').attr('checked',true);
    } else {
        $('.clsborder').attr('checked',false);
    }
};
</script>

<div>
     <input type="checkbox" id="check_all" name="select_all" onclick="checkall();"/>: Check All Box
</div>
<div>
    <input type="checkbox" class="clsborder" name="checkname[]" id="checkname[]" value="1"  /><br/>
    <input type="checkbox" class="clsborder" name="checkname[]" id="checkname[]" value="2"  /></br>
    <input type="checkbox" class="clsborder" name="checkname[]" id="checkname[]" value="3"  /></br>
</div>
 

Thanks for visiting my blog. if you face any problem using this code then contact me through contact form below. and I welcome the query about Adsense or Blogging.

0 comments :

Post a Comment

 
# Top