Google Answers Logo
View Question
 
Q: Disabling button when form is submitted ( Answered,   0 Comments )
Question  
Subject: Disabling button when form is submitted
Category: Computers > Programming
Asked by: stella_uk-ga
List Price: $5.00
Posted: 12 Jan 2005 04:25 PST
Expires: 11 Feb 2005 04:25 PST
Question ID: 456014
I am really struggling to get this to work. I have many forms on my
site, and I need to disable the submit buttons whenever they are
clicked, then submit the form.

I can get it to work in firefox, but IE does not like that code. It
doesnt disable the button

I am looking for a generic solution which I can include in a common
header file, hen add a small tag to each button.

It must work in IE 5+ and Firefox 1.0

Request for Question Clarification by hammer-ga on 12 Jan 2005 04:56 PST
Is this to prevent the form from being submitted more than once?

- Hammer

Clarification of Question by stella_uk-ga on 12 Jan 2005 06:46 PST
Hi yes, thats right. A dialog saying something would be just as good. 
I failed to get this to work on firefox and IE also :-(
Answer  
Subject: Re: Disabling button when form is submitted
Answered By: hammer-ga on 12 Jan 2005 07:05 PST
 
Stella_uk,

Try this first:
IRT.org Javascript FAQ
Q1636 How can I stop a user from hitting the Submit button twice?
http://developer.irt.org/script/1636.htm


If the above doesn't work in all the cases you need to support, here
is an alternate Javascript method:
From Squeaky's JavaScript crib page
http://www.squeaky.demon.co.uk/jn/usforms.htm
-----------------------------------
: I have a problem with people that hit the submit button more that once on my 
: signup form. It creates multiple submissions. Someone told me that there is a 
: javascript that prevents someone from hitting a submit button more than once. 
: Any help regarding this would be appreciated.

In the head of your html, put this script:

<script>
function checkit ()
{
  if (dunnit) {
    alert ("One submission per person!");
    return false;
  } else {	
    alert ("Thank you for your input.");
    dunnit = true;
    return true;
}
var dunnit = false;
</script>

_In_ your submit button tag, put this:
onSubmit="return checkit()"

This runs the above function, which checks to see if dunnit is true.
If it is, the form doesn't submit.  If it is false, it is set to true
and submits. 
----------------------------------


There is also a cookie based method:
NetMechanic
http://www.netmechanic.com/news/vol5/html_no16.htm


Good luck with your web project!

- Hammer

Clarification of Answer by hammer-ga on 12 Jan 2005 07:06 PST
Search Strategy
---------------
prevent form submit "more than once"
Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy