[web] Help with javascript.
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?
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.
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....
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)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement