title: Javascript check dropdown value against textbox
body: <p>I need to check textbox value against dropdown list, and if that value does not exist, add to the list. </p>
  
  <p>I have this script:</p>
  
  <pre><code>            &lt;select id="drop" onchange="ChooseContact(this)"&gt;
                &lt;option value="Volvo Red"&gt;Volvo Red&lt;/option&gt;
                &lt;option value="Mers Blue"&gt;Mers Blue&lt;/option&gt;
                &lt;option value="Ferr red"&gt;Ferr red&lt;/option&gt;
              &lt;/select&gt;
  
  function execute(data) { 
      var txtbox = document.getElementById ("txtServiceReportInspectedBy").value;
          if ( document.createElement('option').value != txtbox ) {
              var categories = document.getElementById("drop");
              var newOption = document.createElement('option');
              newOption.innerText = txtbox ;
              newOption.setAttribute('value', txtbox );
              categories.appendChild(newOption);
          }
      document.getElementById("drop").value = txtbox ;
  }
  </code></pre>
  
  <p>But the new item is still created in the dropdown list, eventhough such item already there. Thanks.</p>