Jump to content

[SOLVED] javascript function call, dynamicly added element...


rempires

Recommended Posts

Hi every, i have a javascript question regarding calling a function from a dynamically added html element.

 

i put the element into a variable and i need to add an onchange call to it

 

i know i can't get it to work in IE i haven't tested Firefox yet(my site keeps blocking me, stupid host... it thought i was flooding it because i accessed to so many times really fast.... so I'm running a IE specific proxy)

 

anyway the code looks something like

function addDDL()
{
var newSelectionDay = document.createElement('select');
newSelectionDay.setAttribute('id',DDLNum+"DDLDay");
newSelectionDay.setAttribute('name',DDLNum+"DDLDay");
newSelectionDay.onchange =dayChange();

//blah all we do ehre is add some options to that drop down lsit
NewDiv.appendChild(newSelectionDay);

}

 

that doesn't work though, the error is obviously this line

newSelectionDay.onchange =dayChange();

 

anyone know how i could add an event to a dynamically added element?

 

thanks,

 

john

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.