homepage Welcome to WebmasterWorld Guest from 184.73.52.98
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
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
NooK




msg:3491562
 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,

document.getElementById('someItemName').onclick();

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

NooK

 

Fotiman




msg:3491584
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved