title: Dynamic option using javascript
body: <p>I trying build dynamic <code>option</code> in <code>combo box</code></p>
  
  <p>In my case I use 4 combo box for example, and for option (1/2/3/4) if user pick option 1 then for the next combo box the option 1 will be gone, and only available (2/3/4).</p>
  
  <p>b1 : 1,2,3,4</p>
  
  <p>b2 : 1,2,3,4</p>
  
  <p>b3 : 1,2,3,4</p>
  
  <p>b4 : 1,2,3,4</p>
  
  <p>If in b1 user select number 1 then for b2-b4 only have 3 option it's (2-3-4) and keep repeated until b4 (b2 select 3 then b3 &amp; b4 only have 2 option it's (2 &amp; 4), next if b3 select 4 then last combo box (b4) only have 1 option it's (2))</p>
  
  <p>HTML :</p>
  
  <pre><code>&lt;select id="b1" name="b1"&gt;
         &lt;option value="1"&gt;1&lt;/option&gt;
         &lt;option value="2"&gt;2&lt;/option&gt;
         &lt;option value="3"&gt;3&lt;/option&gt;
         &lt;option value="4"&gt;4&lt;/option&gt;
  &lt;/select&gt;
  
      &lt;select id="b2" name="b2"&gt;&lt;/select&gt;
      &lt;select id="b3" name="b3"&gt;&lt;/select&gt;
      &lt;select id="b4" name="b4"&gt;&lt;/select&gt;
  </code></pre>
  
  <p>Javascript : </p>
  
  <pre><code>&lt;script src="jquery-1.9.1.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
      $(document).ready(function(){
          var szTr ;
          var a = new Array('1','2','3','4');
          $( '#b1' ).on( 'change', function( e ) {
              for(i=0; i&lt;a.length; i++)
              {
                  if(a[i] == e.value)
                  {
                      unset(a[i]);
                  }
                  else
                  {
                      szTr = szTr + "&lt;option&gt;" + a[i] + "&lt;/option&gt;";
                  }
              }
              $('#b2').append(szTr);
          });
  
          $( '#b2' ).on( 'change', function( e ) {
              // same code like b1
          });
      });
  </code></pre>
  
  <p>I try build in <code>array (1,2,3,4)</code> then check if same <code>unset</code> else <code>append</code> to next <code>combobox</code>.</p>
  
  <p>But it's fail, and keep repeated the option every time select option, (2 times select ) the next combo box option (1,2,3,4,1,2,3,4)  <a href="https://jsfiddle.net/g13mmext/1/" rel="nofollow">Jsfiddle</a></p>
  
  <p>I really appreciate the help.</p>