move listbox items using jqueryhttp://forums.asp.net/t/1789102.aspx/1?move+listbox+items+using+jqueryWed, 04 Apr 2012 12:40:07 -040017891024915779http://forums.asp.net/p/1789102/4915779.aspx/1?move+listbox+items+using+jquerymove listbox items using jquery <p>hi all,</p> <p>let we assume i have listbox A and B, then 2 buttons called Left and Right. my req. is if i click Right then move the item from A to B, so, that i used this code</p> <p><code class="plain">&#36;(</code><code class="string">&quot;#fromListBox&nbsp; option:selected&quot;</code><code class="plain">).appendTo(</code><code class="string">&quot;#toListBox&quot;</code><code class="plain">);</code></p> <p>if the user selects ALL from A then i have to move all data from A to B, for that i used this code</p> <p><code class="spaces">&nbsp;</code><code class="plain">&#36;(</code><code class="string">&quot;#fromListBox option&quot;</code><code class="plain">).appendTo(</code><code class="string">&quot;#toListBox&quot;</code><code class="plain">);</code></p> <p>the real problem is, the data was move from A to B but the data was actually removed from A and added to B. But, i want to keep the data on A as well as B. so, experts please advise me how to resolve this issue.</p> 2012-04-04T11:52:25-04:004915886http://forums.asp.net/p/1789102/4915886.aspx/1?Re+move+listbox+items+using+jqueryRe: move listbox items using jquery <p>Try this</p> <p><strong>&#36;(&quot;#fromListBox&nbsp; option:selected&quot;).clone().appendTo(&quot;#toListBox&quot;);</strong></p> <p><strong>Example:</strong></p> <pre class="prettyprint">&lt;div&gt; &lt;h3&gt;List A&lt;/h3&gt; &lt;select id=&quot;list1&quot; multiple=&quot;multiple&quot; rows=2&gt; &lt;option value=1&gt;Option 1&lt;/option&gt; &lt;option value=2&gt;Option 2&lt;/option&gt; &lt;option value=3&gt;Option 3&lt;/option&gt; &lt;option value=4&gt;Option 4&lt;/option&gt; &lt;option value=5&gt;Option 5&lt;/option&gt; &lt;option value=6&gt;Option 6&lt;/option&gt; &lt;/select&gt; &lt;br/&gt; &lt;input id=&quot;button1&quot; type=&quot;button&quot; value=&quot;Move to List B&quot; /&gt; &lt;/div&gt; &lt;div&gt; &lt;h3&gt;List A&lt;/h3&gt; &lt;select id=&quot;list2&quot; multiple=&quot;multiple&quot; rows=2&gt; &lt;/select&gt; &lt;/div&gt; $(function(){ $(&quot;#button1&quot;).click(function(){ $(&quot;#list1 &gt; option:selected&quot;).each(function(){ $('#list1 option:selected').clone().appendTo(&quot;#list2&quot;); }); }); });</pre> <p><strong><br> </strong></p> 2012-04-04T12:40:07-04:00