Results 1 to 5 of 5

Thread: Disabling form button for a few seconds

  1. #1
    Join Date
    Apr 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Disabling form button for a few seconds

    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:
    Code:
     <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">

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <input type="submit" class="submit" value="get resources" id="ressub" onclick="this.enabled = false;window.setTimeout('document.getElementById(\'ressub\').enabled = true;', 5000);">
    Last edited by Twey; 04-14-2006 at 12:22 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.

    Link?

  4. #4
    Join Date
    Apr 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Perfect, thank you so much!

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Er, yeah, you might want to specify a delay in there somewhere too. Edited.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •