title: getting the value of the selected DropDown menu option
body: <p>So i know there have been many posts about this and ive read them, but the solutions recommended in this previous posts, dont work.</p>
  
  <p>I have a function that dynamically creates me a drop down menu. Here it is:</p>
  
  <pre><code>function date(start, end) {
  
      output ="";
      for(i=start;i&lt;=end;i++)
      {
      output += "&lt;option value='"+i+"'&gt;"+i+"&lt;/option&gt;";
      }
  
      document.write(output);
  
  }
  </code></pre>
  
  <p>And i call it like this:</p>
  
  <pre><code>Month:
          &lt;select name="mm" id="mm" disabled onchange="activateDate();"&gt;
              &lt;script type="text/javascript"&gt;
                  date(1,12);
              &lt;/script&gt;
          &lt;/select&gt;
  </code></pre>
  
  <p>Note: activateDay just changes the attribute disabled in the next dropdown menu, because you should first select a year, then a month, then a day.</p>
  
  <p>and when i try to get the selected value of the month so that i can give a month a number of days (31 for january, 28 for february)like this :</p>
  
  <pre><code>var a = document.getElementById("mm");
  var month = a.options[a.selectedIndex].value;
  </code></pre>
  
  <p>And if i use this vars for a switch which looks for the month and returns the number of the days, then i give the number of days to my <code>date()</code> i get an empty drop down menu for my dates. The Javascript console in chrome says this:</p>
  
  <p><strong>Uncaught TypeError: Cannot read property 'options' of null</strong></p>
  
  <p>And points me to this line: </p>
  
  <pre><code>var month = a.options[a.selectedIndex].value;
  </code></pre>
  
  <p>So what am i doing wrong?</p>