douzhang6176 2015-10-30 19:02
浏览 674

如何从javascript中的jquery.chosen插件多选字段中获取值?

Folks, Let's say that I am using the jquery.chosen plugin:

https://harvesthq.github.io/chosen/

Let's also say that I've been able to dynamically populate a multiple select with values using javascript:

<script type="text/javascript">
function appendToChosen(id,value){
    $('#stuff')
        .append($('<option></option>')
        .val(id)
        .attr('selected', 'selected')
        .html(value)).trigger('chosen:updated');
}
</script>

Where "id" is for a group id, and value is for a unique email address.

BUT, I want to grab all of the selected option values that are populated in the multi-select in javascript, particularly for ajax stuff.

Using something like:

    function rule_add(id)
{
$("#stuff").trigger("chosen:updated");
var url = "scripts/script.php"; // the script where you handle the form input.
$.ajax({
    type: "POST",
    url: url,
    data: $("#idForm").serialize(),// serializes the form's elements.
    success: function(data)
    {
    }
  });
return false;
}

Where the multi-select data is in the form ends up getting posted as:

group_list[] 19

group_list[] 19

group_list[] 19

group_list[] 19

Where the "19" shown above comes from the "id" variable for the group id. I want it to post the values of each which would end up being each separate email address. Any ideas?

Thanks!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器