【发布时间】:2017-11-01 18:12:18
【问题描述】:
我有一个项目列表和任何项目的三种付款类型我想提供所有类型的付款并将付款 id 发送到 ajax 但我只为所有请求提供 id=1 我的代码在这里:
@foreach($project->payments as $payment)
@if($payment->type==1)
@if(empty($payment->code))
<input type="hidden"id="payment_id"value="{{$payment->id}}">
<input type="text" class="form-control" id="paymentCode" name="paymentC">
{{csrf_field()}}
<button id="AddCode" type=submit class="btn btn-info generate-label AddCode">enter</button>
@else
{{$payment->code}}
@endif
@elseif($payment->type==2)
@if(empty($payment->code))
<input type="hidden" id="payment_id" value="{{$payment->id}}">
<input type="text" class="form-control" name="paymentC" id="paymentCode">
{{csrf_field()}}
<button id="AddCode" type="submit" class="btn btn-info generate-label AddCode">enter</button>
@else
{{$payment->code}}
@endif
@endif
@endforeach
Javascript 代码:
$('.AddCode').click (function (event) {
var payment_id = $('#payment_id').val();
var paymentCode = $('#paymentCode').val();
console.log(payment_id);
});
如何解决点击付款按钮时打印此 ID 的问题?
【问题讨论】: