title: Getting value of dropdown box in javascript
body: <p>I'm trying to get the value of a drop down box and keep getting the error Uncaught TypeError: Cannot read property 'selectedIndex' of null.</p>
  
  <p>Heres my code:</p>
  
  <p><strong>JS</strong></p>
  
  <pre><code>expirationYearSelectedIndex = document.getElementById("selYear").selectedIndex;
      console.log("expirationYearSelectedIndex = " + expirationYearSelectedIndex);
  
      expirationYear = document.getElementById("selYear").options[expirationYearSelectedIndex].value;
      console.log("expirationYear = " + expirationYear);
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form action=""&gt;
      &lt;select id="SelYear" name="selYear"&gt;
          &lt;option selected value=""&gt; Select a Major....&lt;/option&gt;
          &lt;option value="Comptuer Information Systems"&gt; CIS&lt;/option&gt;
          &lt;option value="Math"&gt; M&lt;/option&gt;
          &lt;option value="CS"&gt; CS&lt;/option&gt;
          &lt;option value="History"&gt; H&lt;/option&gt;
      &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>