<p>How do I programmatically force an onchange event on an input?</p>

<p>I've tried something like this:</p>

<pre><code>var code = ele.getAttribute('onchange');
eval(code);
</code></pre>

<p>But my end goal is to fire any listener functions, and that doesn't seem to work.  Neither does just updating the 'value' attribute.</p>

if you're using jQuery you would have:
```
```
$('#elementId').change(function() { alert('Do Stuff'); });
```
```
or MS AJAX:
```
```
$addHandler($get('elementId'), 'change', function(){ alert('Do Stuff'); });
```
```
Or in the raw HTML of the element:
```
```
<input type="text" onchange="alert('Do Stuff');" id="myElement" />
```
```
After re-reading the question I think I miss-read what was to be done. I've never found a way to update a DOM element in a manner which will force a change event, what you're best doing is having a separate event handler method, like this:
```
```
$addHandler($get('elementId'), 'change', elementChanged);
function elementChanged(){
  alert('Do Stuff!');
}
function editElement(){
  var el = $get('elementId');
  el.value = 'something new';
  elementChanged();
}
```
```
Since you're already writing a JavaScript method which will do the changing it's only 1 additional line to call.
Or, if you
are
using the Microsoft AJAX framework you can access all the event handlers via:
```
```
$get('elementId')._events
```
```
It'd allow you to do some reflection-style workings to find the right event handler(s) to fire.