SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2013
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    One-time-click element in HTML without js?

    I'm looking for a non-javascript one-time-click implementation. Anyone know of one?

    The idea is I want to put either a button element, an anchor, or a submit input on my page, and have it disable after it's clicked the first time (to prevent multiple clicking). Does such a thing exist without resorting to javascript to detect the click event?

  2. #2
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Not possible without JavaScript
    Ryan B | My Blog | Twitter

  3. #3
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,272
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    The cheese way around that is two identical pages: one with the button/anchor/submit, one without. The old page will still be in their browser history though.

    Another trick that wouldn't work entirely cross browser is, if it's an anchor, something like

    #special:visited {
    display: none;
    }

    sneeeeeky. This'll stay with them until they clear browser history, which might be the moment they close the browser. If you're worried about actual accidental double clicks rather than multiple submissions, this could solve that.

    If your problem is really a slow server where people click multiple times because they don't get the feedback that the first action worked, then you know honestly you need to fix the feedback issue rather than mess with the button :P One possibility is a hidden bit of text underneath the button, and similar technique:
    <a id="special" href="tehbutton">St Elsewhere</a>
    <p>Yr sbmssn iz being processed, yo. kthxbye</p>

    #special+p {
    display: none;
    }
    #special:visited {
    display: none;
    }
    #special:visited+p {
    display: block;
    }


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
  •