I want to attach an eventhandler to a html control in javascript code.
I tried using code like this:
var textBox = document.createElement('textarea'); textBox.setAttribute('cols', '14'); textBox.setAttribute('rows', '3'); textBox.setAttribute('id', GetTextBoxID(mainCell)); textBox.setAttribute('onblur', 'ChangeNodeName(' + textBox.id.toString() + ');');mainCell.appendChild(textBox);
but the eventhandler doesn't execute.
what is the problem?
is there other ways?
Jaish MathewsPosted Apr 28, 2010, 3:31 AM
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");
}