我正在开发一个应用程序,该应用程序的一个部分是客户接收新库存的部分。该部分包含购物车。用户搜索商品并将其添加到购物车中,然后可以指定数量并添加收到的商品的序列号。以下是购物车的代码和结构:
<table class="table table-bordered table-striped" >
<thead>
<tr>
<th>Item</th>
<th>Stock Qty</th>
<th>Serials</th>
<th>Price</th>
<th>Order Qty</th>
<th>Total Price</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
@foreach($rawm as $raw )
<tr>
<td>{{$raw->mname}}</td>
<td>{{$raw->pquant.' '.$raw->units}} </td>
<td><div class="form-group">
@if($raw->serial==1)
<a href="#" data-toggle="modal" data-target="#modal-def{{$raw->gr}}" class="label bg-blue" ><i class="fa fa-plus"></i> <b>Add Serials</b></a>
<div class="modal fade" id="modal-def{{$raw->gr}}">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>
<h4 class="modal-title">Add Serials For <b>:</b> {{$raw->mname}} </h4>
</div>
<form action="{{'/rec_serials'}}" method="GET">
{{csrf_field()}}
<div class="modal-body">
<input type="hidden" name="cart_id" value="{{$raw->grt}}">
<input type="hidden" name="pid" value="{{$raw->gr}}">
<script type="text/javascript">
function add_row()
{
$rowno=$("#employee_table tr").length;
$rowno=$rowno+1;
$("#employee_table tr:last").after("<tr id='row"+$rowno+"'><td><input type='text' name='serial[]' class='form-control' style='width: 100%;' autocomplete='off'></td><td><input type='button' class='btn btn-danger' value='-' onclick=delete_row('row"+$rowno+"')></td></tr>");
}
function delete_row(rowno)
{
$('#'+rowno).remove();
}
</script>
<div class="form-group">
<table id="employee_table" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Serials</th>
<th>Add</th>
</tr>
</thead>
<tr id="row1">
<td> <input type="text" name="serial[]" class="form-control" autocomplete="off" /></td>
<td><input type="button" onclick="add_row();" class="btn btn-info" value="+"></td>
</tr>
</table>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="submit"class="btn btn-primary">Add Serials</button>
</form>
</div>
` `</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
</div>
@else
<center><b>N/A</b></center>
@endif
</div>
</td>
<td width="150">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">Ksh.</span>
<input type="text" class="" name="bp" onChange="in_price({{$raw->gr}}, '{{$raw->bp}}')" id="input-price-{{$raw->gr}}" value="{{$raw->bp}}" autocomplete="off" >
</div>
</div>
</td>
<td><div class="cart-info quantity" style="width: 99px;">
<div class="btn-increment-decrement" onClick="decrement_quantity({{$raw->grt}}, '{{$raw->bp}}')">-</div>
<input class="input-quantity"
id="input-quantity-{{$raw->grt}}" value="{{$raw->cquant}}" onChange="in_quantity({{$raw->grt}}, '{{$raw->bp}}')">
<div class="btn-increment-decrement"
onClick="increment_quantity({{$raw->grt}}, '{{$raw->bp}}')">+</div>
</div></td>
<td><div class="cart-info price" id="cart-price-{{$raw->grt}}">
{{'Ksh.'.$raw->bp * $raw->cquant}}
</div></td>
<td><div class="">
<a href="{{'destroy/'.$raw->grt}}"
class="btnRemoveAction"><img
src="/dist/img/icon-delete.png" alt="icon-delete"
title="Remove Item" /></a>
</div></td>
</tr>
@endforeach
</tbody>
</table>
</div>
用户可以在购物车中放置多个物品。问题是,当购物车中添加了多个项目时,用于添加序列号的动态表格仅适用于第一个项目。我无法在购物车中的后续项目上添加更多输入字段。如果单击添加,它仍会以第一种形式添加输入字段。