简体   繁体   中英

How to POST selected elements in the jQuery Chosen Multiselect

I have a spring based form in order to POST my user registration. Recently, I had to update my form to allow users a project selection. This selection needs a multiselect because it can be more than one option.

My chosen select is like this:

<select name="projects" data-placeholder="Click to choose your project(s)" multiple class="chosen-select" style="width:350px;" tabindex="2">
    <option value=""></option>
    <option value="AA">AA</option>
    <option value="BB">BB</option>
    <option value="CC">CC</option>
</select>

I specified the name attribute to send the param but the behaviour is not the expected one:

projects    AA
projects    BB

The post sends the param twice. How can I do it to send something like.. projects: AA,BB ?

Thank you

这是将值作为数组传递的标准方法:

<select name="projects[]" ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM