【发布时间】:2014-03-10 04:47:59
【问题描述】:
我正在使用 jQuery 插件 (http://harvesthq.github.io/chosen/),但无法将选定的值填充到文本框中。
根据选项页面,它说 $('.my_select_box').trigger('chosen:updated');
但是我确实有多个选择框,比如说
<select id="select1" class="chzn-select" name="select1" data-placeholder="Choose an employee..." multiple="true" style="width: 350px; display: none;"></select>
<select id="select2" class="chzn-select" name="select2" data-placeholder="Choose an employee..." multiple="true" style="width: 350px; display: none;"></select>
<select id="select3" class="chzn-select" name="select3" data-placeholder="Choose an employee..." multiple="true" style="width: 350px; display: none;"></select>
在我的 jQuery 脚本中我确实有
$('.chzn-select', this).chosen(); // do I use this to prepopulate?
但如果我已经在 3 个选择框中选择了值,我该如何再次填充这些值?
我有一个函数可以将它们保存到数据库中:
$("#btnSave").click(function(){
var firstVal= $("#select1").val();
var secondVal= $("#select2").val();
var thirdVal = $("#select3").val();
$.ajax({
type: "post",
url: "myPoST",
data: {
firstVal:firstVal,
secondVal :secondVal,
thirdVal :thirdVal;
},
....// what do I do here?
});
});
非常感谢您的帮助。谢谢!
页面加载时的期望输出:
【问题讨论】:
标签: jquery twitter-bootstrap jquery-chosen