Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Triggering Object Event using getElementByID 2

Status
Not open for further replies.

carlosalvidrez

Programmer
Aug 14, 2002
18
US
Hello,
Is it possible to trigger the event of an object through it's id?

I would like to call the "onClick" event of an object (button, radio, whatever) through getElementByID.

I have tried:
1. document.getElementById( "theIdOfMyObject" ).onClick;
2. document.getElementById( "theIdOfMyObject" ).onClick();

Thanks in advance.
 
Got it... nevermind... sorry.
Here is a sample that works.


<input type=&quot;button&quot; id=&quot;xx&quot; onClick=&quot;alert('clicked!');&quot; value=&quot;click me&quot;>

<input type=&quot;button&quot; onClick=&quot;javascript:document.getElementById('xx').click();&quot; value=&quot;trigger above button&quot;>


I hope this helps someone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top