Disable HTML Submit Button won't display until all JavaScript is Done

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • labmonkey111
    New Member
    • Sep 2008
    • 44

    Disable HTML Submit Button won't display until all JavaScript is Done

    I have a form that takes several seconds to run the javascript needed to prepare the form for PHP (selecting all items in a Select Multiple). Since it takes so long, I want to disable the Submit button and Change the text to "Please Wait..."

    I have the code done, and it sorta works. FireFox3 does not seem to update the page until all JavaScript is done executing, so after the few seconds of nothing happening, then the button is disabled and the form is immediately submitted. IE7 actual does update the page, seeming after EVERY JavaScript line of code. It is ridiculously slow, but the button is disabled so I really don't care too much.

    So how can I force the page to repaint in FireFox (preferably only once after the button is disabled) so the user is aware that something is happening (I just want to avoid them clicking the button multiple time and doing who knows what to the data). I would like to think that JavaScript has some sort of repaint or flush function I can call.

    I appreciate any help.
  • Logician
    New Member
    • Feb 2007
    • 210

    #2
    Originally posted by labmonkey111
    (I just want to avoid them clicking the button multiple time and doing who knows what to the data).
    If you disable the submit button in the first statement of the onsubmit handler, pressing the button again will have no effect regardless of its displayed state.

    There could be ways of speeding-up your code...

    Another way would be to have the onsubmit handler:
    1. Disable the button
    2. Set its value to 'Please Wait'
    3. Set a timeout to call the processing function in 10ms. The processing function calls the submit method.
    4. Return false.

    Comment

    • labmonkey111
      New Member
      • Sep 2008
      • 44

      #3
      Gave it a try, and surprisingly that didn't even do it. Oh, well, its not really a high priority to get it to behave like that anyway, just thought it be a little more user friendly. I may come back to it after the site is closer to being completed. Thanks for the suggestion.

      Comment

      Working...