By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,504 Members | 1,170 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

Does submit count as an onChange event ?

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In article <aa**************************@posting.google.com >, sw*****@rof.net
(S Wickes) writes:
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
Jul 20 '05 #2

P: n/a
> 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
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.