title: Select option removal function
body: <p>The following function is supposed to remove a selected value from the selectbox,
  and update a hidden field with all values.</p>
  
  <p>I have two problems with it:
  Lets say I have the following options in the selectbox : <code>1071,1000,1052</code>
  After removing the first option (1071), the hidden field is getting a value of <code>1052,1000,1000</code>, </p>
  
  <p>if I remove the second option <code>(1000)</code> the hidden field is <code>1052,1052,1071</code>
  if I remove the third one <code>(1052)</code>, I get an <code>options[...].value is null or not an object</code></p>
  
  <p>Can someone plz help me fix this ?</p>
  
  <pre><code>function removeOptions() {
      var selectbox = document.getElementById('zipcodes');
      var zipcodes = document.getElementById('zip');
      var tmpArray = [];
      var i;
      for (i = selectbox.options.length - 1; i &gt;= 0; i--) {
          if (selectbox.options[i].selected){
              selectbox.remove(i);
          }
          tmpArray.push(selectbox.options[i].value);
      }
      zipcodes.value = tmpArray.join(',');
  
  }
  </code></pre>