Handling Duplicate objects in Javascript
<p>I have a javascript method which handles removing from one select box to another.
The code runs as follows :</p>

<pre><code> function moveAllOptions(formName, selectId1, selectId2) {

     var sourceSelect = eval("document." + formName + "." + selectId1);
     var destSelect = eval("document." + formName + "." + selectId2);

     for (var i = 0; i &lt; sourceSelect.length; i++) {  

         var optionText = sourceSelect.options[i].text;
         var optionValue = sourceSelect.options[i].value;

         for (var j = 0; j &lt; destSelect.length; j++) {
             if (destSelect.options[j].value == optionValue) {
                 destSelect.options[j].value = null;
             }
         }

     }

 }
</code></pre>

<p>But I found a problem like when it encounters duplicate values it is not deleting all the values .For eg: in the view source I have</p>

<pre><code>value="139"&gt;Customer Service&lt;
value="231"&gt;Customer Service&lt;
value="231"&gt;Customer Service&lt;
value="231"&gt;Customer Service&lt;
value="231"&gt;Customer Service&lt;
</code></pre>

<p>In this case it removes only two objects from my left hand box.
Is there any way to remove duplicate objects also.One way I could think is create an two array objects(Two Dimensional), pass all the values in left hand side to one array then iterate to another array and finally pass again to normal options.</p>
