title: how to dynamically add options to an existing select in vanilla javascript
body: <p>I'd like to add option to a select dynamically using plain javascript.  Everything I could find involves JQuery or tries to create the select dynamically as well.  The closest thing I could find was <a href="https://stackoverflow.com/questions/7340644/dynamically-add-input-type-select-with-options-in-javascript">Dynamically add input type select with options in Javascript</a> which does the latter and was the only I found that doesn't involve JQuery.  Although I did try and use it like so:</p>
  
  <pre><code>daySelect = document.getElementById('daySelect');
  daySelect.innerHTML += "&lt;option'&gt;Hello world&lt;/option'&gt;";
  alert(daySelect.innerHTML)
  </code></pre>
  
  <p>After I did this there was no change to the select and the alert gave me </p>
  
  <pre><code>HELLO WORLD&lt;/option'&gt;
  </code></pre>
  
  <p>I apologize if this is simple but I'm very new at javascript and web programming in general.  Thank you for any assistance.</p>
  
  <p>EDIT: So I tried the given suggestions like so.</p>
  
  <pre><code>daySelect = document.getElementById('daySelect');
  myOption = document.createElement("option");
  myOption.text = "Hello World";
  myOption.value = "Hello World";
  daySelect.appendChild(myOption);
  </code></pre>
  
  <p>This has not changed the select in the page at all.  Any idea why?  And I did check that the code was being run with an alert.</p>
  
  <p>EDIT: The idea did work, it just turned out that it wasn't displaying a value in the dropdown.  I don't know why but I can figure that one out I think.</p>