title: How to expand an onchange event with JavaScript
body: <p>This is a question I ran into about expanding on an element's JavaScript onchange event.  I have several select elements that conditionally will have one onchange event attached to each of them (when they change to specific values, it hides/unhides certain elements).  I want to conditionally add or append to another onchange event so they set a global variable if they do change without modifying or disabling the previous function already attached to them.  Is there a way to "append" an additional function or add more functionality onto the already existing one?</p>
  
  <p>Here is what I believe an example would be like:</p>
  
  <pre><code>&lt;select id="selectbox1"&gt;
      &lt;option&gt;...&lt;/option&gt;
      &lt;option&gt;...&lt;/option&gt;
  &lt;/select&gt;
  
  if (&lt;certain conditions&gt;) {
      document.getElementById("selectbox1").onchange = function () { 
          //hides elements to reduce clutter on a web form ...
      }
  }
  ....
  if (&lt;other conditions&gt;) {
      document.getElementById("selectbox1").onchange = function2 () {
          //set global variable to false
      }
  }
  </code></pre>
  
  <p>Alternatively I'd like to simply add the 1-liner "set global variable to false" to the original function.</p>