Jump to content
  • Advertisement
Sign in to follow this  
CelticSir

[web] Help with javascript.

This topic is 3708 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
How about using a timer? When the button is clicked, activate the timer for 3 seconds. When the timer fires (after 3 seconds), activate the button.

Share this post


Link to post
Share on other sites
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....

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!