0

我试图弄清楚如何创建一个多选表单,它有两个选择,允许您将条件移动到第三个选择中。我确实看过:

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

// http://www.erichynds.com/jquery/jquery-multiselect-plugin-with-themeroller-support/ (我是新手,所以我只能发布一个链接... :-) )

但它们看起来都只允许一对一的选择,而不是我想要实现的二对一......

像这样的东西:

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

这可能吗?有没有人有一个工作示例或说明这种事情的链接?

4

2 回答 2

1

您需要一个 ID 为“添加”的按钮

进行选择点击添加按钮

将此代码附加到按钮

$('#add').click(function() {  
 return !$('#select1 option:selected,#select2 option:selected').appendTo('#target');  
});
于 2010-03-08T18:25:52.387 回答
0

您可以根据自己的需要进行调整:

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

它从下拉列表中找到选定的项目,将其删除,然后将其附加到目标下拉列表中。

于 2010-03-08T18:20:48.510 回答