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

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

P: 44
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.
Oct 17 '08 #1
Share this Question
Share on Google+
2 Replies


100+
P: 210
(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.
Oct 17 '08 #2

P: 44
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.
Oct 23 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.