delphi programming forums mysql charset mget recursive synonimos
free ventrilo servers hosting cs javascript delay python find in list
Back Forum New
abstract:

<form name="checkstatus" id="checkstatus" method="post" action="<? $_SERVER ?>" onSubmit="return delay(3);">
        <script language="javascript" type="text/javascript">
                function delay(sec) {
                        setTimeout("document.forms.submit();", sec * 1000);
                        return false;
                }
        </script>
Anyone able to help please??
many thanks in advance
td


Hi there,
I am in need for some help on delaying the form submission for 3 seconds. When the submit button is clicked I have a animated loader image that becomes visable and I want the visitor to see it for a few seconds before the form submits.
I have the following so far, however the issue I am having is that the action when the form submits no longer is processed. But if I take the timeout out the action is processed  
Code:
  1. <form name="checkstatus" id="checkstatus" method="post" action="<? $_SERVER[PHP_SELF] ?>" onSubmit="return delay(3);">
  2.         <script language="javascript" type="text/javascript">
  3.                 function delay(sec) {
  4.                         setTimeout("document.forms[0].submit();", sec * 1000);
  5.                         return false;
  6.                 }
  7.         </script>
Copy Code
Anyone able to help please??
many thanks in advance
td

TOP

anyone able to help????  

TOP

Hi
In a world where everyone wants everything NOW NOW NOW, it's strange to see someone actually wanting to delay something.
Personally, I wouldn't impose any un-necessary delay to the end-user, if you want to see a "please wait while loading" screen, use Ajax to process the submitted form data, presenting a "please wait while loading" screen until it is done.  Then, when it's finished, re-direct or display the output to screen.
This way, if the form takes say 10 seconds to actually process, the user's not waiting more than that.  What you're asking for help with (although I am sure is possible) is to increase that even more.
Anyway, just my 2c.
(perhaps move the action to perform to the next line in the function - don't know if that would work or not but if I recall correctly, would only perform the action AFTER the setTimeout function?)
Code:
  1.         <script language="javascript" type="text/javascript">
  2.                 function delay(sec) {
  3.                         setTimeout("", sec * 1000);
  4.                         document.forms[0].submit();
  5.                         return false;
  6.                 }
  7.         </script>
Copy Code
Good luck

TOP

more 2c
I can sometimes see the need for delay, for example if a web app tells me its saved something 'instantly' I'm suspicious.. I'm used to the fractional (1 sec?) delay like gmails "saving..." message. however 3 seems exaggerated.
perhaps you could use badger fruits advice and set a flag so that at the start of the ajax process you show the message "whatever.." and then if the ajax processing takes less than x time you hold off hiding the message until you're comfortable or at least enough time for the message to be read. That way processes that take 5 seconds naturally, aren't getting artificially extended to 8 seconds and super quick processes still feel 'comfortable'

TOP

abstract:

<form name="checkstatus" id="checkstatus" method="post" action="<? $_SERVER ?>" onSubmit="return delay(3);">
        <script language="javascript" type="text/javascript">
                function delay(sec) {
                        setTimeout("document.forms.submit();", sec * 1000);
                        return false;
                }
        </script>
Anyone able to help please??
many thanks in advance
td



Originally Posted by haydenchambers
perhaps you could use badger fruits advice and set a flag so that at the start of the ajax process you show the message "whatever.." and then if the ajax processing takes less than x time you hold off hiding the message until you're comfortable or at least enough time for the message to be read
The problem there is that AJAX has 4 states (or 5 if you want to be picky):-
0 = uninitialized
1 = loading
2 = loaded
3 = interactive
4 = complete
There's no way that I know of of timing how long the response takes and do xyz if the response exceeds a desired period of time.
I appreciate that people may be suspicious if a page you'd expect to take say 3 seconds to load pops up straight away, but I'd rather that then be left wondering "is it even doing anything at all?".

TOP

the time I refer to is perceived time, so as soon as the user clicks the submit button set a var that holds the current time and show the waiting message, then when the ajax response returns (ie complete) measure the time.. if its over our threshold just hide the message if its under set a mini-timeout with the remaining miliseconds before hiding the message.



<form name="checkstatus" id="checkstatus" method="post" action="<? $_SERVER ?>" onSubmit="return delay(3);">
        <script language="javascript" type="text/javascript">
                function delay(sec) {
                        setTimeout("document.forms.submit();", sec * 1000);
                        return false;
                }
        </script>
Anyone able to help please??
many thanks in advance
td

TOP

Back Forum