title: Detect programmatical changes on a html select box
body: <p>Is there a way to make a HTML select element call a function each time its selection has been changed programmatically?</p>
  
  <p>Both IE and FF won't fire 'onchange' when the current selection in a select box is modified with javascript. Beside, the js function wich changes the selection is part of framework so I can't change it to trigger an onchange() at then end for example.</p>
  
  <p>Here's an example:</p>
  
  <pre><code>&lt;body&gt;
  &lt;p&gt;
  &lt;select id="sel1" onchange="myfunction();"&gt;&lt;option value="v1"&gt;n1&lt;/option&gt;&lt;/select&gt;
  &lt;input type="button" onclick="test();" value="Add an option and select it." /&gt;
  &lt;/p&gt;
  &lt;script type="text/javascript"&gt;
      var inc = 1;
      var sel = document.getElementById('sel1');
      function test() {
          inc++;
          var o = new Option('n'+inc, inc);
          sel.options[sel.options.length] = o;
          o.selected = true;
          sel.selectedIndex =  sel.options.length - 1;
      }
  
      function myfunction() {
          document.title += '[CHANGED]';
      }
  &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Is there any way to make test() call myfunction() without changing test() (or adding an event on the button)?</p>
  
  <p>Thanks.</p>