title: How to get previous and new selected value from a option DOM element with JavaScript?
body: <p>How can I retrieve the new selected value and the previous selected value with JavaScript when onChange or similar event is called?</p>
  
  <pre><code>&lt;select size="1" id="x" onchange="doSomething()"&gt;
    &lt;option value="47"&gt;Value 47&lt;/option&gt;
    ...
  
  
  function doSomething() {
    var oldValue = null; // how to get the old value?
    var newValue = document.getElementById('x').selected.value;
    // ...
  </code></pre>
  
  <p>Thank you! :)</p>