homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

How to find which element fired a manually fired event?
An event fired by calling the event function through javascript

5+ Year Member

Msg#: 3491560 posted 4:23 pm on Oct 30, 2007 (gmt 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




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

Msg#: 3491560 posted 4:41 pm on Oct 30, 2007 (gmt 0)

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved