我试图找出如何创建有两个选择,让您的标准进入第三选择一个多选的形式。我也来看看:

http://www.quasipartikel.at/multiselect/

// HTTP://www.erichynds。 COM / jQuery的/ jQuery的多选,插件与 - 的ThemeRoller支持/ (我是新的,所以我只能发布一个链接... :-))

但他们都看起来像他们只允许一到一个选择,而不是两个对一个,我想实现...

像这样:

<!-- user selects multiple values from this and the selected options are moved to third select onclick -->
<select id="select1" name="select1[]" multiple="multiple">
<option value="1">1</option>
<option value="1">1</option>
<option value="1">1</option>
<option value="1">1</option>
<option value="1">1</option>
</select>

<!-- user also selects multiple values from this and the selected options are moved to third select onclick -->
<select id="select2" name="select2[]" multiple="multiple">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
<option value="d">d</option>
<option value="e">e</option>
</select>

<!-- this is the target for the previously selected options -->
<select id="target" name="target[]" disabled>
<!-- all of the selected options from select1 and select2 are placed here onclick -->
</select>

这是可能的?有没有人有工作的例子,或说明了这种事情有关系吗?

有帮助吗?

解决方案

您需要一个按钮的“添加“

的ID

进行选择击中添加按钮

与连接到按钮的代码

$('#add').click(function() {  
 return !$('#select1 option:selected,#select2 option:selected').appendTo('#target');  
});

其他提示

您可能能够定制给你的需求:

$(function() {
    $("#select1, #select2").change(function() {
        $("#target").append($(":selected", $(this)).remove());
    });
});

它发现从下拉列表中选择的项目,删除它,并将其追加到目标下拉。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top