Does submit count as an onChange event ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • S Wickes

    #1

    Does submit count as an onChange event ?

    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
  • HikksNotAtHome

    #2
    Re: Does submit count as an onChange event ?

    In article <aa57bfd3.03092 51549.7764428e@ posting.google. com>, swickes@rof.net
    (S Wickes) writes:
    [color=blue]
    >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?[/color]

    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

    Comment

    • S Wickes

      #3
      Re: Does submit count as an onChange event ?

      > What you are experiencing is a timing issue.[color=blue]
      >[/color]
      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

      Comment

      Working...