title: how to get value from select tag in javascript
body: <p>Hi there i got little problem with Javascript. I populate dropdown menu with database record.</p>
  
  <pre><code>function selectCountry(){
      $result = @mysql_query("SELECT * from country");
      while($record = @mysql_fetch_array($result)){
          echo '&lt;option value="'.$record['countryid'].'"&gt;'.$record['countryname'].'&lt;/option&gt;';
      }
  }
  </code></pre>
  
  <p>and now it's populated with datas, how can i get dropdown menu value in javascript. Here is my html code</p>
  
  <pre><code>&lt;select name="dropdown" onchange="myFunction()"&gt;
  &lt;?php selectCountry(); ?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>when i write javascript function it's said <i>Cannot read property 'options' of null</i></p>
  
  <pre><code>function myFunction(){
      var e = document.getElementById("dropdown");
      var elementValue = e.options[e.selectedIndex].value;
      console.log(elementValue);
  }
  </code></pre>