title: Get selected value in dropdown list using JavaScript
body: <p>How do I get the selected value from a dropdown list using JavaScript?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form&gt;
    &lt;select id="ddlViewBy"&gt;
      &lt;option value="1"&gt;test1&lt;/option&gt;
      &lt;option value="2" selected="selected"&gt;test2&lt;/option&gt;
      &lt;option value="3"&gt;test3&lt;/option&gt;
    &lt;/select&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>