Sign in to follow this  
thefollower

[web] Help with javascript.

Recommended Posts

In php i have two time stamps in two variables: $now and $time What im looking to do is find if the difference between the time of "now" on the server to the time of "$time" has exceeded 3 seconds difference. When it does, i want javascript to display something as a means of flood control. I have the flood control coded in php too encase users have javascript turned off. But would like the javascript to do it as a means of making the site more friendly to use. The idea is.... when the button is pressed which stores that moment in time as $time. Then javascript counts 3 seconds from that moment! Whilst it is below 3 seconds it does not display the submit button, then once the 3 seconds passed the submit displays on the form again. Is this possible in javascript?

Share this post


Link to post
Share on other sites
Quote:
Original post by thefollower
Is this possible in javascript?

Sure.
Quote:
Original post by thefollower
I had that how ever once timer ran to 0 it would allow the button, but once pressed the second time it would no longer count down, so it would only do it the one time....

Then fix your code. Start the timer again after the button was pressed:
function onButtonPress()
{
button.hide();
setTimeout(showButton, 3000);
}

function showButton()
{
button.show();
}

(pseudo code)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this