首页 > 解决方案 > 在同一个表中更新和删除

问题描述

在我的项目中,我有表格(图片)。有复选框列,当用户检查记录并按下删除按钮时,记录将被删除。多数民众赞成在工作正常。

然后是可见的列(布尔值),默认情况下(真)。因此,当检查记录并单击隐藏/显示按钮时,它将更新可见值(从 1 到 0 或从 0 到 1)

我的问题是,删除和显示/隐藏按钮单独工作。我希望两者同时工作。我不知道如何将它们组合在同一张桌子上。

这是我的观点(仅显示/隐藏工作)

<button type="submit" class="btn btn-danger" id="deleteImg"><i class="fa fa-trash"></i> Delete</button>
<form action="{{url('admin/images/hideimg')}}" method="post" class="form-inline">
                {{csrf_field()}}
                {{method_field('post')}}
                <div class="pull-right form-group" style="padding: 12px">
                    <button class="btn btn-warning"  id="hideImg">
                        Hide/Show</button>
                </div>


            @if($images)

                <table class="table panel panel-default" id="table">
        <thead class="panel-heading">
        <tr>
            <th><input type="checkbox" id="options"> </th>
            <th>Visible?</th>
            <th>photo</th>
            <th></th>
        </tr>
        </thead>
            <tbody id="tablecontents" class="panel-body">


                @foreach($images as $image)

            <tr class="row1" data-id="{{ $image->id }}">
                <td><input class="checkboxes" type="checkbox" id="option" name="checkBoxArray[]" value="{{$image->id}}" data-imageid="{{$image->id}}"></td>
                <td>{{$image->visible == 1?'yes':'no'}}</td>
                <td  ><img src="/uploads/{{$image->path}}" id="img" ></td>
                  <td>

                     </td>
            </tr>
                @endforeach

            </tbody>

    </table>

            @endif

            </form>

表单操作=“删除/图像”方法=“发布”类=“表单内联”>

    {{csrf_field()}}
    {{method_field('delete')}}
    <div class="modal fade" id="modalDelete" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
        <div class="modal-dialog " role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h2 class="modal-title"  style="text-align: center" id="modalLabel">Delete Confirmation</h2>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <h5 class="text-center">Are you sure you want to delete the following service?</h5>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-warning pull-left" data-dismiss="modal">
                        <span class='glyphicon glyphicon-remove'></span> Close</button>
                    <button type="submit" class="btn btn-danger" name="delete_all" value="Delete">
                        <span id="" class='glyphicon glyphicon-trash'></span> Delete</button>
                </div>
            </div>
        </div>
    </div>
</form>

标签: javascriptphplaravel-5.5

解决方案


推荐阅读