I want to attach an eventhandler to a html control in javascript code.
I tried using code like this:
Code
var textBox = document.createElement('textarea');Code
textBox.setAttribute('cols', '14');Code
textBox.setAttribute('rows', '3');Code
textBox.setAttribute('id', GetTextBoxID(mainCell));Code
textBox.setAttribute('onblur', 'ChangeNodeName(' + textBox.id.toString() + ');');Code
mainCell.appendChild(textBox);but the eventhandler doesn't execute.
what is the problem?
is there other ways?

Jaish MathewsRank #225 · 11K reputationPosted Apr 27, 2010, 11:31 PM EDT
Event attach should be like this,
//No double quotes needed as we are doing ByRef and not ByVal.
textBox.onblur = function(){HandleOnBlur();};
function HandleOnBlur()
{
alert("Fired");
}