View Full Version : How to simulate a button click?

06-22-2005, 07:34 PM
How might I simulate a button click w/ Javascript?

I am not asking how to call code that an event invokes. I want to fire the event itself.

Why don't I just create my own eventHandler and call it myself? Because I don't know how our form-building tool implemented it. It's not exposed for programmatic use.

Willy Duitt
06-22-2005, 08:03 PM

06-22-2005, 08:25 PM
as in getElementById("button name").click ?

Willy Duitt
06-22-2005, 08:27 PM
as in getElementById("button name").click ?

yeppers... :thumbsup:

06-23-2005, 06:12 AM
Should be document.getElementById("button Id").click()
But that only works in IE. To make it work in Firefox, you have to do this (http://www.codingforums.com/showpost.php?p=34595&postcount=5).

06-23-2005, 06:36 AM
What about object.onclick();?

Oh, nevermind... wasn't paying attention. ;)