Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

How to find which element fired a manually fired event?

An event fired by calling the event function through javascript

4:23 pm on Oct 30, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:June 15, 2007
votes: 0

I have a dynamic form which uses javascript events and such to hide and show parts of the form.

I am trying to make it so that the user can go back to the form relevant to that data and correct some of the fields but to do that I need to be able automatically show the proper parts of the form.

I can fill the fields correctly but just filling them won't fire events like onclick.

I am able to get which events to fire and fire them manully by calling, for example,


but the problem is that I added the events to the fields with a general function checking for the srcElement and doing the appropriate things depending on which element was fired, such as,

var obj = event.srcElement;

if(obj.name == 'SomeName'){ doSomething}
else if......

And what happens when I try calling document.getElementById('someItemName').onclick(); is that it gives me an error because it cannot find event.srcElement.

Is there any solution to this one? How can I fire events manually (So the user doesn't have to click a checkbox, for example, which is already checked just to fire the onclick event).

Best Regards


4:41 pm on Oct 30, 2007 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
votes: 21

You might consider using the Yahoo UI Library [developer.yahoo.com]'s Event Utility [developer.yahoo.com] to create your own Custom Events [developer.yahoo.com]. This will allow you to programmatically fire your events, and has the added benefit of cross-browser functionality without you needing to worry about it.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members