开发者

Passing multiple values with hidden input fields

开发者 https://www.devze.com 2023-01-03 19:49 出处:网络
With a select tag, it is possible to post multiple values using only HTML by selecting more than one option?

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 wi开发者_StackOverflow社区th HTML.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消