This is a discussion on "[SOLVED] Event Chain detection" within the JavaScript Forum section. This forum, and the thread "[SOLVED] Event Chain detection are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
[SOLVED] Event Chain detection
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
[SOLVED] Event Chain detection
There is an onchange event handler attached to the INPUT element on the FORM. There are also two buttons Submit and Cancel that process form data.
I would like to detect if the onchange event handler for the form INPUT element occured as a result of user clicking on the Cancel button. In this case validation logic in the onchange event handler should not be activated. Is there a way to detect this in JavaScript? Thank you, Stan. |
|
|
|
||||
|
Re: Event Chain detection
I didn't think the reset button triggered the onchange event but if it does, it would be easy to avoid...
Just set a global variable.. and then set it to true when the cancel button is clicked... In your onchange function, just add some logic to aviod going any further in the function...
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: Event Chain detection
This is exactly the issue itself:
the onclick handler is called only after the onchage handler completes. the flag will be set after onchange and have no use in this case. Is there such thing as an event queue in JS? I am puzzeled how to solve this one. Regards, Stan. |
|
||||
|
Re: Event Chain detection
Instead of using onclick for the cancel button use onmousedown instead. Then when the mouse button is pressed down the variable is set. The actual reset functionality won't happen until a full click is completed
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: Event Chain detection
Rakuli, Great idea!
Really solves a lot of my application design problems. The sequence of events noted: onmousedown onchange onclick Thank you, Stan. |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] Stop Propagation event after onchange Select!!!! | abdoukadri | JavaScript Forum | 8 | Dec 5th, 2007 20:50 |
| [SOLVED] Os Detection | simonb | PHP Forum | 16 | Nov 26th, 2007 23:59 |
| Chain Email Surveys... Grrr! | Rakuli | Webforumz Cafe | 6 | Oct 18th, 2007 17:50 |
| ie mac detection | jimz | JavaScript Forum | 2 | Jul 27th, 2006 22:07 |
| EVENT: SPARK - Flash Event | Flasher | Flash & Multimedia Forum | 0 | Nov 15th, 2005 10:08 |