title: Code to detect option value does not work as expected
body: <p>I was attempting to do some string comparisons in javascript. I have seen several tutorials and examples but they do not seem to work. I am missing something fundamental?</p>
  
  <p>Attempt 1</p>
  
  <pre><code>function addAspect(aspect) {
      var print = document.createElement('p');
      var ptext;
  
      if (aspect == "Option1") ptext = document.createTextNode("This is option1");
  }
  </code></pre>
  
  <p>Doesnt work.</p>
  
  <p>Then I found this example to which all readers said it worked fine</p>
  
  <pre><code>function addAspect() {
      var print = document.createElement('p');
      var ptext;
  
      var aspect = String(document.getElementById("aspectResult").value);
  
      if (aspect == "Option1") ptext = document.createTextNode("This is option1");
  }
  </code></pre>
  
  <p>Doesnt work.</p>
  
  <p>I also tried <code>.toString()</code> as well as the <code>'==='</code> exact match comparison.</p>
  
  <p>Full code</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
      &lt;script type="text/javascript"&gt;
          function addAspect()
          {
              var print = document.createElement('p');
              var ptext;
              var aspect = document.getElementById("aspectResult").value;
              if (aspect == "Option1"){
                  ptext = document.createTextNode("This is option1");
              }
              print.appendChild(ptext);
              document.getElementById("mainBlock").appendChild(print);
          }
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form&gt;
              &lt;select id="aspectResult"&gt;
                  &lt;option value="Option1"&gt;Option1&lt;/option&gt;
              &lt;/select&gt;
              &lt;input type="button" value="Check" onclick="addAspect()"/&gt;
          &lt;/form&gt;
          &lt;span id="mainBlock"&gt;&amp;nbsp&lt;/span&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Any suggestions?</p>