View Full Version : how to fire the onchange event programmatically?

03-14-2005, 08:42 AM
Hello all.
I have an urgent question and I wish someonene could answer:
Is it possible to fire the onchange (for a dropdownlist) event programmatically from javascript?
Actually I have created a function to link two Dropdownlists in a Parent-Child relation, but the problem is that if I have more than two level relation betwen my DDLs, the onchange event doesn't fire for the non direct ChildDDL.

For example, I have a function
loadChildOptions(ParentDDL, ChildDDL){
//function to change ChildDDL options relatively to ParentDDL
//ChildDDL.selectedIndex=0; but the onchange event of ChildDDL doesn't fire
I need to fire the onchange for ChildDDL from the loadChildOptions function.
Any idea about this?

03-14-2005, 10:11 AM
Have you tried:ChildDDL.onchange();? :)

03-14-2005, 11:23 AM
Hi codegoboom, thanks a lot, now it works.
I have tried before ChildDDL.onchange (without parenthesis) and it didn't work, now ChildDDL.onchange(); is working.
But I have a question about this method compatibility.

03-14-2005, 11:48 AM
I'll guess that would come down to which events you're calling... btw, onchange.call(); seems to work too. ;)