首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在单击表单提交按钮(Laravel)时更改php值

问如何在单击表单提交按钮(Laravel)时更改php值
EN

Stack Overflow用户
提问于 2020-10-14 16:02:38
回答 1查看 150关注 0票数 0

这是我的代码:

代码语言:javascript
复制
@php
   $id = 1;
@endphp

<form action="{{route('upload.submit_rencana_kerja_bulanan',$id)}}" method="post">
{{ csrf_field() }}
<!-- Begin body content -->
<div class="card-body">
    {{-- TABLE --}}
    <!-- Begin body content -->
    <div class="table-responsive">
        <table data-toggle="table" data-height="460" data-width="600" data-search="true" data-visible-search="true" data-show-columns="true"
            data-show-footer="false">
            <thead>
                <tr>
                    <th data-sortable="true">Nomor</th>
                    <th data-sortable="true">ID</th>
                    <th data-sortable="true">Customer</th>
                    <th data-sortable="true">Outlet</th>

                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
                @foreach ($masterCustomer as $masterCustomers)
                    <tr>
                        <td>{{$nomorTable2}}</td>
                        <td>{{$masterCustomers->id}}</td>
                        <td>{{$masterCustomers->customer_name}}</td>
                        <td>{{$masterCustomers->customer_outlet}}</td>

                        <td class="text-center">
                            <a href="{{url('add_customer/'. $masterCustomers->id . '/' . $emp_name . '/' . $date . '/rencana_kerja_bulanan')}}">
                                <button class="btn btn-success" type="submit">
                                    Add
                                </button>
                            </a>
                        </td>
                    </tr>

                    @php
                        $nomorTable2++;
                    @endphp
                @endforeach

            </tbody>
        </table>
    <!-- end of body content -->
    </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>

                {{-- <button id="btnsubmit" class="btn btn-success" type="submit">
                    Submit Data
                </button> --}}
            </div>
        </div>
        </div>
    </div>
    {{-- SAMPAI SINI MODALNYA --}}
</div>
</form>

我想要将$id = 1;值更改为用户在单击表中的按钮后将在表中选择的值

你能用这个方法改变这个值吗?

不能添加更多的代码,因为stackoverflow不允许我这样做,对很多代码它说

EN

回答 1

Stack Overflow用户

发布于 2020-10-14 16:07:47

您不能使用javascript更改PHP值。我认为您可以在表单中使用隐藏字段,并在单击按钮时更改隐藏字段的值。当表单被post时,你可以从该隐藏字段中获取id的值。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64349034

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档