Javascript: "onchange" event does not work with "value" change in "text input" object

Viewed 55984

I have a javascript input object with type="text" coming along with an onchange event which is created by (related lines):

var id_box = document.createElement('input');
id_box.id = 'id_box';
id_box.type = 'text';
id_box.onchange = function()
{
    alert("Changed!");
}

For changing this value in this input field I use:

var a = document.createElement('a');
a.innerHTML = "A";
a.onclick = function()
{
    document.getElementById('id_box').value = 'A';
}

The onchange event works only changing value by keyboard typing but not for changing value by above function. Is there any way to make this works?

Please take a look at this: http://jsfiddle.net/zCMdV/7/

1 Answers
Related