Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用JQuery从Laravel5.2中的一些复选框中获取选中的复选框ID_Javascript_Jquery_Checkbox - Fatal编程技术网

Javascript 如何使用JQuery从Laravel5.2中的一些复选框中获取选中的复选框ID

Javascript 如何使用JQuery从Laravel5.2中的一些复选框中获取选中的复选框ID,javascript,jquery,checkbox,Javascript,Jquery,Checkbox,我在laravel 5.2中提出了如下观点: <table class="table table-condensed table-bordered table-hover"> <tr> <th>Report</th> <th>Type</th> <th>Date</th> </tr> <?php $index = 0; ?> @f

我在laravel 5.2中提出了如下观点:

<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-[{{$data->id}}]"  id="{{$data->id}}" >{{$data->title}}</input></td>
         <td><b>{{$data->report_type}}</b></td>
         <td>{{$data->created_at}}</td>
      </tr>
   @endforeach

 </table>
但这些都是未定义的。。。有没有办法获取这些复选框的ID。。??提前感谢:)

我也试过:

console.log($("input[name=reports-1]").map(function()
                {
                  return  this.id;
             }));

但它返回的是一个对象,而不是复选框ID。请查看您的代码
name=“reports-[{{{$data->id}}]”
应替换为
name=“reports-{{{$data->id}}”
。在复选框输入标记的名称值中,它包括
[]
。但是,您的
控制台中没有
[]
。当然,它将返回undefined,因为它与复选框输入标记中的任何名称值都不匹配。

查看您的代码
name=“reports-[{{{$data->id}}]”
应替换为
name=“reports-{{{$data->id}}”
。在复选框输入标记的名称值中,它包括
[]
。但是,您的
控制台中没有
[]
。当然,它将返回未定义,因为它与复选框输入标记中的任何名称值都不匹配。

您的
$data->id
是否只包含数字?iyaps。。。它只包含数字David先生:)您的
$data->id
是否只包含数字?iyaps。。。它只包含数字David先生:)对不起,大卫先生。我改了,又试了一次。。但它仍然提供一个未定义的日志…:)尝试删除输入名称值中的
[]
。Coool。。。问题来自[…],。。。我不知道为什么我的朋友建议我使用[…]。对不起,大卫先生。我改了,又试了一次。。但它仍然提供一个未定义的日志…:)尝试删除输入名称值中的
[]
。Coool。。。问题来自[…],。。。我不知道为什么我的朋友建议我使用[…]。
console.log($("input[name=reports-1]").map(function()
                {
                  return  this.id;
             }));