Debt Consolidation - Manga - Shopping news - Kamala Harris - Debt Consolidation

PDA

View Full Version : add event handler to element created using JS


obiron
Feb 20th 2007, 6:36 am
Having given up on trying to get IE6 to add innerHTML containing additional elements, I am now creating each element and adding it to the DOM manually.

One of the elements needs to take an onkeyup event which then calls the JS and runs an AJAX call. When dynamically generating the original source HTML using PHP the HTML looks like this.

<input type="text" name = "name_2" id = "name_2" size=20 onkeyup="fn_getCustomerInfo(2);"/>

Where the 2 is passed through the ajax call to determine the target of the results and is therefore different on each line.

I can set the type, name and id in JS using
elementobj.name = 'name_' + nextcounter;
elementobj.id = 'name_' + nextcounter
elementobj.size='20';

how do I set the onkeyup event handler?

nico_swd
Feb 20th 2007, 6:48 am
Try:

elementobj.onkeyup = function()
{
fn_getCustomerInfo(2);
}