Hyosoka Poipo Hyosoka Poipo - 2 months ago 9x
Javascript Question

How to get selected checkbox ID from some checkboxes in Laravel 5.2 using JQuery

I have made a view in laravel 5.2 like this :

<table class="table table-condensed table-bordered table-hover">
<?php $index = 0; ?>
@foreach($tableContent as $data)
<?php $index++; ?>
<td><input type="checkbox" name="reports-[{{$data->id}}]" id="{{$data->id}}" >{{$data->title}}</input></td>


And then I want to get the id of checked checkbox in my controller. I have tried to use these code :


But those are undefined... Is there a way to get the ID of these checkboxes..?? Thanks in advance :)

I also have tried this :

return this.id;

But it returns an object, not the checkbox ID


Take a look at your code. name="reports-[{{$data->id}}]" should be replace as name="reports-{{$data->id}}". In your name value in the checkbox input tag, it includes []. But, there is no [] in your console.log. Of course, it will return undefined as it will not match with any of your name value in the checkbox input tag.