質問

私はあなたが第三の選択に基準を移動するための2つの選択を持っている複数選択フォームを作成する方法を把握しようとしています。私は見てみましょうでします:

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

// ます。http://www.erichynds。 COM / jqueryの/ jqueryの-複数選択 - プラグインと-ThemeRollerのサポート/ に (:-) ...私は新しいので、私は1つのリンクのみを投稿することができます)。

しかし、彼らは唯一ではなく、一対一の選択を可能と同様に、それらの両方が見える2対1の私が実装したいのですが...

このような何かます:

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