从多个选择中发布值

时间:2022-06-26 13:21:29

How can I post values from a multiple select in a form? When I hit submit none of the selected values are posted.

如何在表单中发布多个选择的值?当我点击提交时,没有发布任何选定的值。

<form id="form" action="" method="post">
    <div>
        <select id="inscompSelected" multiple="multiple" class="lstSelected">
            <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>

1 个解决方案

#1


100  

You need to add a name attribute and since it's a multiple select you need the array symbol [] at the end.

您需要添加一个名称属性,因为它是一个多重选择,您需要最后的数组符号[]。

<select name="something[]" id="inscompSelected" multiple="multiple" class="lstSelected">

#1


100  

You need to add a name attribute and since it's a multiple select you need the array symbol [] at the end.

您需要添加一个名称属性,因为它是一个多重选择,您需要最后的数组符号[]。

<select name="something[]" id="inscompSelected" multiple="multiple" class="lstSelected">