Results 1 to 3 of 3

Thread: disable button

  1. #1
    Join Date
    Dec 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default disable button

    I'm looking like this script: http://dynamicdrive.com/dynamicindex11/submitonce.htm

    I want to disable a button for the next 6 hours.
    Reason: I want the code for special section of my page called "lost passwords".

    Regards

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Hmm I'm not 100% certain I understand, but to disable a submit button, you merely use the "disabled" attribute inside the tag:

    Code:
    <input id="abutton" type="submit" disabled="disabled" value="submit" />
    Alternately, in your script, you can do:

    Code:
    document.getElementById("abutton").disabled=true //disable button
    document.getElementById("abutton").disabled=false //enable button

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This could be done with javascript, theoretically. I am assuming you want any given user, once they have used this button, to not be able to do so again for 6 hours.

    Here is the scenario:

    1 ) The page loads, javascript checks to see if they have a cookie that tells it to disable the button, if so, the button is disabled, if not -
    2 ) They click the button.
    3 ) Javascript drops said cookie on their computer, setting it to expire in 6 hours.

    This is all well and good if javascript is enabled and the user doesn't clear their cookies. Many users automatically clear cookies after each session, some anti-spyware programs clear them virtually the moment that they are set. Any user may elect to manually clear cookies at any time.

    The bottom line being that if this is at all critical or meant as a secure method for disallowing repeated use of this button, you should find another method. Server side code would be well suited to this. Something like PHP or ASP.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •