[Javascript] Sumitting a selection every 4 seconds

Chris T christ at saeweb.com
Thu May 20 07:59:24 CDT 2004


Here's some pseudo-code:
-----------------------------------
var objTimer
function selectionMade(){
    objTimer.clearTimeout()
    objTimer = setTimeout("functionName()", 3000)
}
-----------------------------------

You'll notice that your timer has to be global. If you ever check the
contents of a setTimeout you'll see that it's just a number that lets you
reference the timer. So if you clear the timer, you can start it again.  You
may have to do some checks to make sure the timer isn't null, but I'm not
sure about that.

You'll only ever generate one timer when you set a reference to it, whereas
with your code:

-----------------------------------
setTimeout("refresh(" + dest + ")",2500);
-----------------------------------

You will generate a new timer each time and not have a handle to the old
one.  Let us know if that helps you.

Chris Tifer


----- Original Message ----- 
From: "Terry Riegel" <riegel at clearimageonline.com>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Wednesday, May 19, 2004 5:24 PM
Subject: Re: [Javascript] Sumitting a selection every 4 seconds


> Just a quick followup to my question.
>
> Here is a more simplified version of my question.
>
> I would like to have a link when clicked on wait 3 seconds then submit
> a form.
> If another link is clicked before the three seconds then it would stop
> the first link from submitting, and it would submit the form 3 seconds
> after it was clicked.
> The form would not be submitted until the last link was clicked and 3
> seconds after that click had expired.
>
> The point is to keep connections to the server to a minimum.
>
> Thanks,
>
> Terry
>
>
> On May 19, 2004, at 5:14 PM, Terry Riegel wrote:
>
> > you can check it out at
> >
> > http://client1.riegels.com/pages/start/filemanager/filemanager.html
> >
> > Make sure "Sticky" is selected to see how the multiple selections work
> >
> > Thanks for any help,
> >
> > Terry Riegel
> >
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list