SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict sleepingdanny's Avatar
    Join Date
    Oct 2002
    Location
    Israel
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How Do I Disable The Submit Button After One Click On It?

    Can you help me please? I need a function that can disable the submit button after the user clicked on it once so he wont be able to click it twice or more...

  2. #2
    SitePoint Zealot
    Join Date
    May 2002
    Location
    RI-USA
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sleepingdanny
    Can you help me please? I need a function that can disable the submit button after the user clicked on it once so he wont be able to click it twice or more...
    I know you can do it in javascript. Not sure about php. I found this on javascriptsource.com awhile back. Haven't tested it at all

    Code:
    <!-- TWO STEPS TO INSTALL DISABLE SUBMIT:
      1.  Copy the coding into the HEAD of your HTML document
      2.  Add the last code into the BODY of your HTML document  -->
    <!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->
    <HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Web Site:  http://dynamicdrive.com -->
    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->
    <!-- Begin
    function disableForm(theform) {
    if (document.all || document.getElementById) {
    for (i = 0; i < theform.length; i++) {
    var tempobj = theform.elements[i];
    if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
    tempobj.disabled = true;
    }
    setTimeout('alert("Your form has been submitted.  Notice how the submit and reset buttons were disabled upon submission.")', 2000);
    return true;
    }
    else {
    alert("The form has been submitted.  But, since you're not using IE 4+ or NS 6, the submit button was not disabled on form submission.");
    return false;
       }
    }
    //  End -->
    </script>
    </HEAD>
    <!-- STEP TWO: Copy this code into the BODY of your HTML document  -->
    <BODY>
    <center>
    <form onSubmit="return disableForm(this);">
    Name: <input type=text name=person>
    <input type=submit><input type=reset>
    </form>
    </center>
    <p><center>
    <font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
    by <a href="<A href='http://javascriptsource.com">The'>http://javascriptsource.com">The JavaScript Source</a></font>
    </center><p>
    <!-- Script Size:  1.33 KB -->

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Affordable PHP Hosting.....
    http://www.markhost.co.uk


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
  •