我正在试图弄清楚如何创建一个多选表单,它有两个选项,允许您将条件移动到第三个选择。我确实看过:
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>
这可能吗?有没有人有一个工作的例子,或一个说明这种事情的链接?
答案 0 :(得分:1)
您需要一个ID为“add”的按钮
使选择点击添加按钮
将此代码附加到按钮
$('#add').click(function() {
return !$('#select1 option:selected,#select2 option:selected').appendTo('#target');
});
答案 1 :(得分:0)
您可以根据自己的需要量身定制:
$(function() {
$("#select1, #select2").change(function() {
$("#target").append($(":selected", $(this)).remove());
});
});
从下拉列表中找到所选项目,将其删除,然后将其附加到目标下拉列表。