HighDots Forums  

Does submit count as an onChange event ?

Javascript JavaScript language (comp.lang.javascript)


Discuss Does submit count as an onChange event ? in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
S Wickes
 
Posts: n/a

Default Does submit count as an onChange event ? - 09-25-2003 , 06:49 PM






I've become suspicious that the submit button does not count as an
onChange event in some browsers. Here's why.

I have a form with many textareas. After you click submit, I only
update the database with those textareas which were changed.

Thus, each textarea has an onChange event which marks that box as
changed.

BUT! Some users report that, if they don't take their cursor out of
the last text box they were editing, the text in that last textarea
does not get written to the database. (In other words, the onchange
event in that last textarea never got triggered.)

My question: With some browsers, if you leave your cursor parked in
the last box you were editing, and then press submit, why is onChange
not being triggered?

Thanks to all who respond,
Steve

Reply With Quote
  #2  
Old   
HikksNotAtHome
 
Posts: n/a

Default Re: Does submit count as an onChange event ? - 09-25-2003 , 08:53 PM






In article <aa57bfd3.0309251549.7764428e (AT) posting (DOT) google.com>, swickes (AT) rof (DOT) net
(S Wickes) writes:

Quote:
BUT! Some users report that, if they don't take their cursor out of
the last text box they were editing, the text in that last textarea
does not get written to the database. (In other words, the onchange
event in that last textarea never got triggered.)

My question: With some browsers, if you leave your cursor parked in
the last box you were editing, and then press submit, why is onChange
not being triggered?
What you are experiencing is a timing issue.

Cursor is in text area, mouse pushes down on the Submit button, the onChange
gets fired, the form gets submitted. If the form happens to get submitted
before JS has time to mark the field as changed, you get the behavior you
describe.

Without going into a diatribe about relying on javascript, one possible
solution is instead of a submit button, use a normal input type=button and set
its onclick to call a function that will setTimeout to wait 300 ms or so, and
then programatically submit the form. You would be surprised how much
javascript can get executed in 300ms.
--
Randy


Reply With Quote
  #3  
Old   
S Wickes
 
Posts: n/a

Default Re: Does submit count as an onChange event ? - 09-26-2003 , 06:06 PM



Quote:
What you are experiencing is a timing issue.

Randy,

Thanks for your reply. What you say makes sense. Are certain browsers
or javascript versions more suceptible to this timing issue? This
problem always happens for some of my clients, and never happens for
others.

-Steve


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.