如何插入多个具有相同名称的选择输入

时间:2019-11-29 01:11:59

标签: php laravel

是否可以用相同的输入名称插入多个值?我的问题是我收到多个值。

<div class="giftcard box">
    <select name="price" id="colorselector2" style="width:150px;">
        <option value="">Select Gift Card Price</option>
        @foreach($productDetails->giftattributes as $price)
        <option value="{{$price->price}}">$ {{$price->price}}</option>
        @endforeach
    </select>
</div>
<div class="giftcertificate box">
    <select name="price" id="colorselector" style="width:150px;">
        <option value="">Select Gift Certificate Price</option>
        @foreach($productDetails->giftattributes as $price)
        <option value="{{$price->price}}">$ {{$price->price}}</option>
        @endforeach
    </select>
</div>
<div class="productasgift box">
    <select name="price" id="colorselector1" style="width:150px;">
        <option value="">Select Product As Gift Certificate</option>
        @foreach($allproduct as $allprice)
        <option value="{{$allprice->price}}">$ {{$allprice->price}}</option>
        @endforeach
    </select>
</div>

2 个答案:

答案 0 :(得分:0)

尝试在名称的末尾添加[],然后在请求中,所有具有相同名称的选择/输入都应位于数组中

答案 1 :(得分:0)

取消所有选择值。

<select name="price[]" id="colorselector2" style="width:150px;">

<option value="{{$price->id}}">$ {{$price->price}}</option>