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



这是我的代码:

@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不允许我这样做,对很多代码来说,它说

您不能使用javascript更改PHP值。我认为你可以在表单中选择一个隐藏字段,然后点击按钮更改隐藏字段的值。当表单发布时,您可以从该隐藏字段中获取id的值。

最新更新