Re: onChage event
- From: "Anthony Jones" <Ant@xxxxxxxxxxxxxxxx>
- Date: Thu, 6 Sep 2007 10:59:38 +0100
"Ayush" <"ayushmaan.j[aatt]gmail.com"> wrote in message
news:OoKNRe15HHA.3740@xxxxxxxxxxxxxxxxxxxxxxx
[Markgoldin] wrote-:
I am sripting a page that has a dropdown list. While I can set its value
I can't fire its onChange event witch runs a function.
Can I run this function programmatically or how can I trigger the
onChange event from the script?
if(selectElement.onchange)
selectElement.onchange()
That will probably work in most of the common scenarios. However if an
event handler has been added with attachEvent or addEventListener those
handlers won't run by calling onchange.
In IE you can simply use selectElement.fireEvent('onchange').
In Mozilla it is a little trickier. The following will work for Firefox:-
var ev = document.createEvent("Event")
ev.initEvent("change", true, false); // can bubble, can't cancel.
selectElement.dispatchEvent(ev)
--
Anthony Jones - MVP ASP/ASP.NET
.
- Prev by Date: Re: Calling ActiveX component method from JScript
- Next by Date: Re: Proper coding? (JS newbie)
- Previous by thread: I don't know how to adequately describe this...
- Next by thread: offestTop et scrollTop always zero
- Index(es):
Relevant Pages
|
Loading