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.

Read Also:  Laravel Edit DropDown Option Seleted Example

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 :

Read Also:  jQuery Disable Mouse Right Click Examples

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.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  How to add Bootstrap Tooltip Plugin Example
  2. Read Also:  How To Configure Supervisor For Laravel 5/6/7 Queue Jobs?
  3. Read Also:  Handling Arrays using jQuery Tutorial with Examples
  4. Read Also:  How To Capitalize The First Letter Of A String In JavaScript
  5. Read Also:  How to Open URL in New Tab using c#
  6. Read Also:  how to get last inserted id in laravel 6
  7. Read Also:  Read Connection String from Web.Config file in ASP.Net using C# and VB.Net
  8. Read Also:  Browser Features of the Opera web browser Free VPN
  9. Read Also:  Browser Features of the Opera web browser Free VPN
  10. Read Also:  How To Capitalize The First Letter Of A String In JavaScript
CLOSEX