View Full Version : Disabling form button for a few seconds

04-13-2006, 10:37 PM
I have an online game and I am having trouble with players trying to hold down the submit button to gain extra resources, I know I can disable it, but I only want it to disable for a few seconds, and I do not want to send them an alert. I am thinking something like a settimeout? Is there a way to do this? I am having trouble figuring this one out.

This is the part of the form I want to disable:

<input type="text" class="input" size="5" maxlength="25" name="spins" value="<?if($usr[defaultTurn] != 0){ echo"$usr[defaultTurn]"; }?>"> turns collecting resources.
<br><input type="hidden" name="keyboard" value="enter"><input type="submit" class="submit" value="get resources">

04-13-2006, 10:53 PM
<input type="submit" class="submit" value="get resources" id="ressub" onclick="this.enabled = false;window.setTimeout('document.getElementById(\'ressub\').enabled = true;', 5000);">

04-13-2006, 10:54 PM
EDIT: Nevermind . Twey answered before me. Ignore this.

PHP is server side... not gonna allow you to do anything in realtime without refreshing the page (or using "ajax", which is basically javascript dynamically refreshing the page through in-the-background code so it doesn't look like its refreshing)...
basically, you need to use javascript for this. Not sure how, exactly.


04-13-2006, 11:14 PM
Perfect, thank you so much!

04-14-2006, 12:22 PM
Er, yeah, you might want to specify a delay in there somewhere too. :o Edited.