带有data-toggle =“ table”的表格内的复选框不适用于表单

时间:2019-12-28 19:29:05

标签: php jquery bootstrap-4

我使用这个库:https://examples.bootstrap-table.com/index.html#welcome.html

当我将数据包含在表data-toggle="table"中并单击按钮发送数据时,该数据将不起作用。 没有data-toggle="table",我没问题,它可以正常工作,而且我看到了我所有的$ _POST数据。 结果:array(2) { ["btSelectAll"]=> string(2) "on" ["id"]=> string(2) "14" }

谢谢。

<?php
 echo HTML::form('delete_all', $this->link('Products&DeleteAll&cPath=' . $current_category_id));
?>
    <a onClick="$('delete').prop('action', ''); $('form').submit();"
                   class="button"><?php echo HTML::button($this->getDef('button_delete'), null, null, 'danger'); ?></a>&nbsp;
 <table
    id="table"
    data-toggle="table" ===> removed no problem


    data-sort-name="selected"
    data-sort-order="asc"
    data-toolbar="#toolbar"
    data-buttons-class="primary"
    data-show-toggle="true"
    data-show-columns="true"
    data-toolbar=".btn-primary"
    class="table table-md table-hover table-striped"
    data-mobile-responsive="true"
  >
<thead class="dataTableHeadingRow">
    <tr>
      <th  width="1" class="text-md-center"><input type="checkbox" onClick="$('input[name*=\'selected\']').prop('checked', this.checked);"/></th>
      <th class="text-md-center" data-sortable="true"><?php echo $this->getDef('id'); ?></th>
      <th></th>
</tr>
</thead>
<tbody>
<?php
while ......
?>
<tr>

<?php // select all the product to delete
  if (isset($_POST['selected'])) {
?>
    <input type="checkbox" name="selected[]" value="<?php echo $Qproducts->valueInt('products_id'); ?>" checked="checked"/>
<?php
  } else {
?>
    <input type="checkbox" name="selected[]" value="<?php echo $Qproducts->valueInt('products_id'); ?>"/>
<?php
  }
?>
          </td>
              <td><?php echo $Qproducts->valueInt('products_id'); ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</form>

0 个答案:

没有答案