如何在jQuery Chosen Multiselect中张贴选定的元素(How to POST selected elements in the jQuery Chosen Multiselect)

编程入门 行业动态 更新时间:2024-10-07 10:18:48
如何在jQuery Chosen Multiselect中张贴选定的元素(How to POST selected elements in the jQuery Chosen Multiselect)

我有一个基于spring的表单,以便发布我的用户注册。 最近,我不得不更新我的表单以允许用户选择项目。 这种选择需要多选,因为它可以有多个选项。

我选择的选择是这样的:

<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>

我指定了name属性来发送参数,但行为不是预期的行为:

projects AA projects BB

该帖子发送了两次参数。 我该怎么做才能发送像..项目:AA,BB?

谢谢

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[]" ...

This is the standard way to pass values as an array:

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

更多推荐

本文发布于:2023-08-07 13:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464133.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:元素   如何在   Chosen   Multiselect   jQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!