martin.mishat's avatar

How to keep the selected checkboxes checked while pagination?

Greetings, new to Laravel. Using 5.3 and loving it. Having a problem with my checkboxes while pagination. I want to keep the selected checkboxes checked while pagination. Is there any way using 'appends' or 'session' or something else. Codes until now is provided below.

Form with a chekcbox:

  <form id="cforms" method="post">                  

            @foreach($cforms as $candidates)                 

            <tr>  

            <td>

            <input type="checkbox" name="checkbox" value= "{{$candidates->s_id}}" >

            </td>

            <td>{{$candidates->s_id}}</td>

            <td><img src="/uploads/cimage/{{ $candidates->cimage}}" style="width:200px;                                                  height:200px;"></td>

            <td>{{$candidates->planguage}}</td> 

            <td>{{$candidates->cproject}}</td>

            <td>{{$candidates->event}}</td>

            <td>{{$candidates->docs}}</td>

            <td>{{$candidates->created_at}}</td>

            </tr>

            @endforeach

          </table></br>

    {{$cforms->links()}}

         @endunless 

  </form>

Controller:

class cviewcontroller extends Controller { // public function cpview(){

    $candidates = DB::table('cforms')

             ->where('position', 'President')

                             ->paginate(5); 

    return view('cform.cpview', ['cforms' => $candidates]);
    }

} Let me know if I have to provide anything else. Any help would be greatly appreciated. Thank you.

0 likes
2 replies

Please or to participate in this conversation.