This question is a follow up of post Failed to set event handler in javascript
I want to add an event handler for input text controls. The input box control is generated dynamically. My code is like:
_inputbox = document.createElement("input");
_inputbox.type = "text";
_inputbox.id = settings[zindex];
_inputbox.onblur = checkName;
checkName() is defined previously. But when I input something in the box and move the focus to other control, the checkName() isn't executed.
In the DOM tab of Firebug, I find the onblur is assigned to checkName() correctly.
In the HTML tab of Firebug, I find the input box only defines an "ID" and a "type". No "onblur" in its HTML code. If I edit the HTML and add onblur=checkName() manually. The function can be called successfully.
HTML code
<input type="text" id="Datastore">
Is there anyone can help me? Thanks a lot.
checkName
in the scope where you assign it? – Felix Kling