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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.