Programmatically manipulating DOM element value doesn't fire onchange event

Posted by Johan Fredrik Varen on Stack Overflow See other posts from Stack Overflow or by Johan Fredrik Varen
Published on 2010-05-16T01:11:07Z Indexed on 2010/05/16 1:20 UTC
Read the original article Hit count: 304

Filed under:
|
|

Hi all.

I've got a hidden form field, and when a button gets pressed the value of the hidden field is changed. Now, I've added an observer to the hidden field, listening for changes to occur. For some reason, though, the event listener never kicks in, even though the value of the hidden element changes. I'm using Prototype and Firefox 3.6.

The code looks roughly like this:

button.observe('click', function(event) {
  hiddenField.setValue(someValue);
});

hiddenField.observe('change', function(event) {
  alert('It works!');
});

Does anyone have a clue why the latter observer doesn't execute?

Thanks!

© Stack Overflow or respective owner

Related posts about prototype

Related posts about event