title: dynamic select box adding and removing its options dynamically in js
body: <p>I have a button on click of it, I'am crating a select box dynamically with 4 options, the first option will be "select value" the rest are "aaa","bbb","ccc" now what I need is, when I select aaa as an  option  in the select box, and now when I click on the button I will get the second select box, but the aaa option shouldn't be there, and when I change the first select option  from aaa to bbb the aaa option should appear again in the select box. and the rest is same as the above. Kindly provide a solution for this . Any help would be appreciated.</p>
  
  <pre><code>&lt;button id="addIdButton" style="display:block;" onclick="addId()"&gt;clickMe&lt;/button&gt;
  &lt;div id="place"&gt;&lt;/div&gt;
  &lt;script&gt;
      function addId() {
          var location = document.getElementById("place"); 
          var div = document.createElement("div");
          var span = document.createElement("span");
          var select = document.createElement("select");
          select.setAttribute("id","selectID" );
          select.setAttribute("onchange","hideId(this.value,'selectID','option0','option1')" );
          var option0 = document.createElement("option");
          option0.setAttribute("id","option0" );
          option0.innerHTML="select";
          select.appendChild(option0);
          var option1 = document.createElement("option");
          option1.setAttribute("id","option1" );
          option1.innerHTML="aaaa";
          select.appendChild(option1);
          var option2 = document.createElement("option");
          option2.innerHTML="bbbb";
          select.appendChild(option2);
          var option3 = document.createElement("option");
          option3.innerHTML="cccc";
          select.appendChild(option3);
          span.appendChild(select);
          div.appendChild(span);
          location.appendChild(div);
      }    
  &lt;/script&gt;
  </code></pre>
  
  <p>I really don't understand how to do it and check for all the conditions. Above is the creation code, please help with the deletion code.</p>