Laravel how to post values from a multiple select

首先,記得在你的 select tag 的 name 後面加上括號[],這樣子在複選後,傳到後端去的時候才會取得到複選的所有值。

使用 dd() 函式印出,就可以看到陣列裡面包含選住的值

First , remember to add parentheses [] after the name of your select tag, so that after the select, all the checked values will be obtained when it is passed to the backend.

Use the dd() function to print out, you can see that the array contains the selected value.

<form id="form" action="" method="post">
<div>
<select id="number" name="number[]" multiple="multiple">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input type="submit" value="submit" />
</div>
</form>