title: How to get the selected value from dropdown list through javascript and set the value selected in java bean?
body: <p>How can I get the current value of a selected dropdown list value using Javascript?<br>
  I have a user contact form in which I have a dropdown list and the value selected in the list must be captured by javascript function and then pass this value to the controller and set the bean value and then persist the value in database.</p>
  
  <p>The list is like,</p>
  
  <pre><code>&lt;select id="ddl"&gt;
      &lt;option value="val1"&gt;Optoion 1&lt;/option&gt;
      &lt;option value="val2" selected="selected"&gt;Option 2&lt;/option&gt;
      &lt;option value="val3"&gt;Option 3&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>To return the string from the list</p>
  
  <pre><code>var e = document.getElementById("ddl");
  var selected = e.options[e.selectedIndex].val();
  </code></pre>
  
  <p>Which would make <code>selected</code> be <code>val2</code></p>
  
  <p>How do I access this value in Java class and store the value in database?</p>