SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    ǖber abstrakt's Avatar
    Join Date
    Dec 2001
    Location
    Earth
    Posts
    261
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Weird form problem, need solution !!

    I have an interesting situation on my hands, and I can't seem to code the proper solution. being at the end of my rope I've decided to ask any of you who are willing for help.

    I have a form in which customers for support requests, and they keep pressing thebutton like 18 million times, so I end up with numerous amounts of the same request. This is of course very messy, and not any fun to deal with. The current record is 18 of the same request within a minute.

    The proposed solution:
    I once saw a while back on HP's website that when you clicked their form button (an image) it would disappear and leave a static image that says "please wait while processing".

    This idea seemed ingenious to me, but I can't figure out how to get it to work. I've gotten close, and can get my whole form to disappear, lol, but I'd like the submit image of the form to disappear and be replaced with a similar as explained above. this way they can't click it a million times while the server processes the variables.

    Can any of you guys code this to work ? I'd be using <input type=image> of course.

    Any help is appreciated, thanks !


  2. #2
    SitePoint Guru
    Join Date
    Sep 2001
    Location
    Vancouver
    Posts
    809
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I understand your problem. I certainly have had the same thing happen to me. I have seen scripts that can help you do this, or simply disable the Submit button once clicked.

    I would recommend searching through Dynamic Drive.

    I'll start looking as well. If I find something, I'll post here.

  3. #3
    SitePoint Guru
    Join Date
    Sep 2001
    Location
    Vancouver
    Posts
    809
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found what you are looking for. Put the code below into the <head> section of your page.

    Code:
    <script>
    
    /*
    Submit Once form validation- 
     Dynamic Drive (www.dynamicdrive.com)
    For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
    */
    
    function submitonce(theform){
    //if IE 4+ or NS 6+
    if (document.all||document.getElementById){
    //screen thru every element in the form, and hunt down "submit" and "reset"
    for (i=0;i<theform.length;i++){
    var tempobj=theform.elements[i]
    if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
    //disable em
    tempobj.disabled=true
    }
    }
    }
    </script>
    Then put this on the form that you want it to work on.

    Code:
    <form method="POST" onSubmit="submitonce(this)">
    This will disable the Submit button once clicked, process the page without going somewhere else and display an alert message to the user. To see how it works, go here:

    http://www.dynamicdrive.com/dynamici...submitonce.htm

    Hope this helps.

  4. #4
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Assuming you're not performing any for validation, it's as easy as this (IE4+, NS6/Moz):
    Code:
    <input type="submit" name=""Submit" onclick="this.disabled=true;">
    If you ARE doing form validation, then you can disable the button from your validation script in a similar way.
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  5. #5
    ǖber abstrakt's Avatar
    Join Date
    Dec 2001
    Location
    Earth
    Posts
    261
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very well Davin and M@rco.

    Davin, the script worked perfect, except for the fact that I am using an image <input type=image>

    M@rco, havenot tried yours yet, assuming it will pose the same problem. Am I correct, or will your work with an image as submit button.

    Thanks much !


  6. #6
    SitePoint Guru
    Join Date
    Sep 2001
    Location
    Vancouver
    Posts
    809
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My name is Darin, not Davin.

  7. #7
    ǖber abstrakt's Avatar
    Join Date
    Dec 2001
    Location
    Earth
    Posts
    261
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    Sorry bout' that Darin.

    Thanks for the help

  8. #8
    SitePoint Guru
    Join Date
    Sep 2001
    Location
    Vancouver
    Posts
    809
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's okay. You're welcome!

  9. #9
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The script that Darin posted is a better script to use than my one-liner (his detects the browser, and disables ALL submit buttons in the form), but they both work in essentially the same way, so don't bother with mine!

    However, what is the specific problem you are having? Have you changed the script to reflect the fact it's an image input type and it STILL doesn't work?
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!


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
  •