dimanche 14 août 2016

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">
  <tr>
     <th>Report</th>
     <th>Type</th>
     <th>Date</th>
  </tr>
  <?php $index = 0; ?>
   @foreach($tableContent as $data)
      <?php $index++; ?>
      <tr>
         <td><input type="checkbox" name="reports[]"  id="" ></input></td>
         <td><b></b></td>
         <td></td>
      </tr>
   @endforeach

 </table>

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

console.log($("input[name=report-1]").attr("id"));
console.log($("input[name=report-1]").val());

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




Aucun commentaire:

Enregistrer un commentaire