Laravel Check and uncheck all checkbox using jquery

Today, We want to share with you Laravel Check and uncheck all checkbox using jquery.In this post we will show you Check/Uncheck All CheckBoxes using Laravel, hear for Check and Uncheck all checkbox using Laravel Example we will give you demo and example for implement.In this post, we will learn about How to Select / Deselect All Checkboxes using Laravel with an example.

Laravel Check and uncheck all checkbox using jquery

There are the Following The simple About Laravel Check and uncheck all checkbox using jquery Full Information With Example and source code.

As I will cover this Post with live Working example to develop Check Uncheck All Checkbox using Laravel, so the Laravel select all checkboxes in table column for this example is following below.

index.html

<html lang="en">
<head>
    <title>Laravel Select and deselect all checkboxes using jquery</title>
    <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
  <ul>
    <li><input name="category_all" class="select_all" type="checkbox">Select All</li>
    <li><input value="1" name="category" class="checkbox gst" type="checkbox">Product 1  </li>
    <li> <input value="2" name="category" class="checkbox gst" type="checkbox">Product 2  </li>
    <li><input value="3" name="category" class="checkbox gst" type="checkbox">Product 3  </li>
    <li><input value="4" name="category" class="checkbox gst" type="checkbox">Product 4  </li>
    <li><input value="5" name="category" class="checkbox gst" type="checkbox">Product 5 </li>
   </ul>
    <script type="text/javascript">
        $('.select_all').on('change', function() {     
                $('.checkbox').prop('checked', $(this).prop("checked"));              
        });
        //deselect "checked all", if one of the listed checkbox category is unchecked amd select "checked all" if all of the listed checkbox category is checked
        $('.checkbox').change(function(){ //".checkbox" change 
            if($('.checkbox:checked').length == $('.checkbox').length){
                   $('.select_all').prop('checked',true);
            }else{
                   $('.select_all').prop('checked',false);
            }
        });
    </script>
	<a href="https://www.pakainfo.com/" target="_blank" alt="pakainfo" title="pakainfo">Free Download Example - Pakainfo.com</a>

</body>
</html>

Select and Clear all check-boxes using Laravel

HTML Form

@extends('app')
@section('content')

    <h1>Welcome! Send e-mail to selected Members.</h1>
    <hr>
    {!! Form::open(array('action' => '[email protected]','method' => 'GET','name'=>'f1' , 'id'=>'form_id'))!!}
    <br/>
        @foreach($members as $member)
            <div class="form-group">
            {!! Form::checkbox("status[]", $member->email, null,['id' => $member->email], ['class' => 'questionCheckBox']), $member->email !!}
            <br/>
            </div>
        @endforeach
    <div class="form-group">
    {!! Form::submit('Send Mail',['class' => 'btn btn-primary span3']) !!}
    </div>

    <div class="form-group">
    {!! Form::button('Select All',['class' => 'btn btn-default span3','onClick'=>'select_all("status", "1")']) !!}
    </div>

    <div class="form-group">
    {!! Form::button('Clear All',['class' => 'btn btn-danger span3','onClick'=>'select_all("status", "0")']) !!}
    </div>

    {!! Form::close() !!}
@stop
@endsection

Simple Js Code

<script type="text/javascript">

    var userfrmBlock;
    var userfrmData;

    function prepare() {
        userfrmBlock= document.getElementById('form_id');
        userfrmData = userfrmBlock.getElementsByTagName('input');
    }

    function select_all(name, value) {
        for (i = 0; i < userfrmData.length; i++) {
            var regex = new RegExp(name, "i");
            if (regex.test(userfrmData[i].getAttribute('name'))) {
                if (value == '1') {
                    userfrmData[i].checked = true;
                } else {
                    userfrmData[i].checked = false;
                }
            }
        }
    }

    if (window.addEventListener) {
        window.addEventListener("load", prepare, false);
    } else if (window.attachEvent) {
        window.attachEvent("onload", prepare)
    } else if (document.getElementById) {
        window.onload = prepare;
    }
</script>

Angular 6 CRUD Operations Application Tutorials

Read :

Also Read This ๐Ÿ‘‰   Create Dynamic Image Fancybox Gallery with jQuery, PHP & MySQL

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel Check and uncheck all checkbox using jquery.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donโ€™t forget to share.