Passing multiple values with hidden input fields

我是研究僧i 提交于 2019-11-29 11:03:34

问题


With a select tag, it is possible to post multiple values using only HTML by selecting more than one option?

For example:

<select multiple="" >
    <option value="1"/>
    <option value="2"/>
    <option value="3"/>
</select>

Is it possible to pass more than one value as one would achieve with the previous example using one or more <input type="hidden"> fields? Again, strictly with HTML.


回答1:


Use [ ] in the field name to send multiple values:

<input type="hidden" name="your_field_name[]" value="1" />
<input type="hidden" name="your_field_name[]" value="2" />
<input type="hidden" name="your_field_name[]" value="3" />

You will get an array of values in the your_field_name field.



来源:https://stackoverflow.com/questions/3073001/passing-multiple-values-with-hidden-input-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!