title: Jquery remove/append item from multiple select to multiple select
body: <p>I have 3 multiple selects. In the first Select1(left) I load a group of modules. In the 3rd Select3(right) I load another group of modules. The user can select from the Left and hit an add to remove the item from the Left and append it to the Select2(Middle). The user can do the same with the Right, select items hit a different add where the selections will be appended to the middle and removed from the Right.</p>
  
  <p>This all works fine. </p>
  
  <p>I want to enable the user to remove from the Middle multi-select. I only want one occurence of the remove . If the user selects items that were formally contained in both the Left and Right multi-select I want them to be removed from the Middle and appended to the Left and Right according from where the orignially came from. 
  I have a variable setup to determine where the module selected in the middle originally came from.</p>
  
  <p>Im having problems with the actual append/removal of the ITEM from the middle back to the Left / Right multiple selects. Ive googled and tried various things but its taking too long.</p>
  
  <p>The following script shows only the interaction with the Left and Middle selects. I will use any solutions as a model for the Middle, Right relationship.</p>
  
  <p>Any help would be greatly appreciated</p>
  
  <pre><code>&lt;script src="js/jquery.js" type="text/javascript"&gt;&lt;/script&gt;  
  &lt;script type="text/javascript"&gt;  
   $().ready(function() {  
    $('#add_mod').click(function() {  
     return !$('#select1_mod   option:selected').remove().appendTo('#select2_mod');
    });  
    $('#remove_mod').click(function() {  
     var x = "&lt;%= str(modules) %&gt;";  
     $("#select2_mod option:selected").each(function (i,selected) {  
      var thismod = $(this).text();  
      if (x.match(thismod))   
       // HELP Here I want to append this item (text and value) to Select1  
       // HELP Plus, remove this item from Select 2
                             //else after I get a solution for Left/Middle   
     });  
                      // HELP And then return Select1, Select2, Select3  
    });  
   });  
  &lt;/script&gt;  
  </code></pre>