Steve  -  here's several different javascripts I collected when I was
trying to solve the same problem.  The bottom one (submit wait) is one
I'm using.  I can't verify the others - some I got working and some I
didn't, but I don't remember which.

Enjoy!

> -----Original Message-----
> From: Fogelson, Steve [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, April 15, 2004 4:25 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: Witango-Talk: Select a submit button in a form (OT)
> 
> 
> I think I am going to incorporate 2 or 3 of the ideas. Java 
> script looks good. I should double check for products already 
> added. I have to add a little bit to this as I allow product 
> options as well and will have to check them as well.
> 
> I believe I am using a single threaded ODBC for my db. Still 
> working on some issues with the multi threaded version. So 
> this may be a cause as well. Not ready to move to an array 
> based cart but will consider that.
> 
> Thanks for all the ideas.
> 
> Steve
> 
> -----Original Message-----
> From: Dave Shelley [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 15, 2004 4:12 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Witango-Talk: Select a submit button in a form (OT)
> 
> 
> Steve,
> 
> On your form tag, add onSubmit="return(checkSubmit())" 
> and add a javascript function that says:
> 
> var submitted=false;
> function checkSubmit()
> {
>   if (submitted==false)
>   {
>     sunmitted=true;
>     return true;
>   }
>   else
>   {
>     alert('Already submitted');
>     return false;
>   }
> }
> 
> That should do it.
> 
> Dave.
> 
> -----Original Message-----
> From: Fogelson, Steve [mailto:[EMAIL PROTECTED] 
> Sent: April 15, 2004 4:40 PM
> To: Witango User Group (E-mail)
> Subject: Witango-Talk: Select a submit button in a form (OT)
> 
> I am having problems with shoppers selecting the "Add To 
> Cart" button repeatedly. It all happens within a few seconds. 
> They are probably impatient when the server is busy.
> 
> Is there a way to display something immediately when the 
> shopper selects the button to indicate we are processing?
> 
> Thanks for any ideas
> 
> Steve Fogelson
> Internet Commerce Solutions 
> ______________________________________________________________
> __________
> TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
> 
> ______________________________________________________________
> __________
> TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
> ______________________________________________________________
> __________
> TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
> 

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
===================================================================================

//script from http://www.rgagnon.com/jsdetails/js-0110.html

<script>
 var submitDone = false;
 
 function submitForm(myForm, button) {
   
      if (!submitDone) {
         submitDone = true;
         button.value = 'Please Wait';
         button.disabled = true;
         myForm.submit();
      } 
      else {
        alert ("Already submitted, please wait!");
      }
   return true;
 }
 </script>
 
 <form name="longsubmit" 
       action="http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?query=foo";>
   Impossible to submit multiple times
     <input type="button" value="Go" 
     onClick="return submitForm(document.longsubmit, this)">
 </form>


===================================================================================

<script type="text/javascript">

/*
Block multiple form submission script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact for use
*/

//Enter error message to display if submit button has been pressed multiple times 
below.
//Delete below line if you don't want a message displayed:

var formerrormsg="You\'ve attempted to submit the form multiple times.\n Please reload 
page if you need to resubmit form."

function checksubmit(submitbtn){
submitbtn.form.submit()
checksubmit=blocksubmit
return false
}

function blocksubmit(){
if (typeof formerrormsg!="undefined")
alert(formerrormsg)
return false
}

</script>


<form>
"
<input type="submit" value="Submit" onClick="return checksubmit(this)">
</form> 

===================================================================================


function SubDisable(dform) {
  if (document.getElementById) {
   for (var sch = 0; sch < dform.length; sch++) {
    if (dform.elements[sch].type.toLowerCase() == "submit") 
dform.elements[sch].disabled = true;
   }
  }
return true;
}



<form onSubmit="SubDisable(this);">
Value: <input type="text" name="dvalue">
<input type="submit" value="Test This">
</form>


===================================================================================




<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var submitcount=0;

   if (submitcount == 0)
      {
      submitcount++;
      return true;
      }
   else 
      {
      alert("This form has already been submitted.  Thanks!");
      return false;
      }
//  End -->
</script>
</HEAD>

<!-- STEP TWO: Insert the onLoad event handler into your BODY tag  -->

<BODY OnLoad="reset()">

<!-- STEP THREE: Copy this code into the BODY of your HTML document  -->

<form method=post action="http://cgi.freedback.com/mail.pl"; name="emailform" 
onSubmit="return checkFields()">

<input type=hidden name=to value="[EMAIL PROTECTED]">
<input type=hidden name=subject value="Feedback Form">

<pre>
Your Name:   <input type=text name="name">
Your Email:  <input type=text name="email">

Comments?

<textarea name="comments" wrap="virtual" rows="7" cols="45"></Textarea>

<input type=submit value="Submit Form!">

[ Click the submit button twice to see the script in action ]
</pre>
</form>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com";>The JavaScript Source</a></font>
</center><p>


</body>
</html>







===================================================================================



Once again, someone clicked your submit button twice. 

Now you have another duplicated free for all link. Or you have a duplicate email from 
your feedback form. Or your subscription form has just generated two subscription 
requests. 


Here are the two simple steps that can give you some peace: 

(1)
Insert this somewhere in the <head> and </head> section of your HTML page: 

=== JavaScript insert begins on next line ===
<script language="JavaScript">
<!-- Copyright 2000 by William and Mari Bontrager.
counter = 0;
function count() {
counter++;
if(counter > 1) {
if(counter > 2) { return false; }
alert('Sometimes the servers are a bit slow. ' + 
'One click is sufficient.\n\nI\'m sure the ' + 
'server will respond in a few seconds.\n\n' + 
'Thank you for your patience.');
return false;
}
return true;
} // -->
</script>
=== JavaScript insert ends on previous line ===



(2)
Insert this within your <input type="submit" ... > form tag: 

onClick="return count()" 

That's all there's to it. 

Now, whenever someone clicks the submit button a second time, they will get a 
diplomatic message saying that only one click is required and that the server should 
be responding in a few seconds. It only works for browsers which are JavaScript 
enabled, which is most browsers in use today. (The message is presented only once 
because a browser we tested would crash when the message was presented twice and the 
"OK" button was clicked after the CGI program answered.) 

The second and subsequent clicks from your visitor never reach your CGI program, only 
the first click. 

If your <input type="submit" ... > form tag looked like this before the change: 

<input type="submit" value="Send"> 

It would look like this after the change: 

<input onClick="return count()" type="submit" value="Send"> 

The message in the alert box may be changed to whatever you prefer. The message text 
is between the apostrophes (single quotes). If you have an apostrophe within your 
message, type a reverse slash before the apostrophe. To insert a line break, use: 

\n 

If you would rather not display any message but still trap second and subsequent 
submit button clicks, use the following code in your <head> and </head> section of 
your HTML page (instead of the code presented earlier): 

=== JavaScript insert begins on next line ===
<script language="JavaScript">
<!-- Copyright 2000 by William and Mari Bontrager.
counter = 0;
function count() {
counter++;
if(counter > 1) { return false; }
return true;
} // -->
</script>
=== JavaScript insert ends on previous line === 

A demonstration page is at http://willmaster.com/possibilities/demo/singleclick.html 
The CGI program behind the form has an intentional ten second delay to give you plenty 
of time to do multiple clicks on the submit button. 

Have fun! 

William Bontrager, Programmer and Publisher
"WillMaster Possibilities" ezine
http://willmaster.com/possibilities/ 
Copyright 2000 by William Bontrager
 
===================================================================================



<!-- TWO STEPS TO INSTALL SUBMIT CHANGER:

  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">
<!-- Original:  Mike Fernandez -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function submitForm(s)  {
s.value = "  Sending...  ";
return true;
}
//  End -->
</script>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document  -->

<BODY>

<center>
<form name=myform onSubmit="return submitForm(this.submitbutton)">
Name:  <input type=text name=firstname size=20>
<input type=submit name=submitbutton value="All Done">
</form>
</center>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com";>The JavaScript Source</a></font>
</center><p>

<!-- Script Size:  0.87 KB -->


===================================================================================



<!-- THREE STEPS TO INSTALL SUBMIT ONCE:

  1.  Copy the coding into the HEAD of your HTML document
  2.  Add the onLoad event handler into the BODY tag
  3.  Put the last coding into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var submitcount=0;

function reset() {
document.emailform.name.value="";
document.emailform.email.value="";
document.emailform.comments.value="";
}

function checkFields() {                       // field validation -
if ( (document.emailform.name.value=="")  ||   // checks if fields are blank.
     (document.emailform.email.value=="") ||   // More validation scripts at
     (document.emailform.comments.value=="") ) // forms.javascriptsource.com
   {
   alert("Please enter your name, email, and comments then re-submit this form.");
   return false;
   }

else 
   {
   if (submitcount == 0)
      {
      submitcount++;
      return true;
      }
   else 
      {
      alert("This form has already been submitted.  Thanks!");
      return false;
      }
   }
}
//  End -->
</script>
</HEAD>

<!-- STEP TWO: Insert the onLoad event handler into your BODY tag  -->

<BODY OnLoad="reset()">

<!-- STEP THREE: Copy this code into the BODY of your HTML document  -->

<form method=post action="http://cgi.freedback.com/mail.pl"; name="emailform" 
onSubmit="return checkFields()">

<input type=hidden name=to value="[EMAIL PROTECTED]">
<input type=hidden name=subject value="Feedback Form">

<pre>
Your Name:   <input type=text name="name">
Your Email:  <input type=text name="email">

Comments?

<textarea name="comments" wrap="virtual" rows="7" cols="45"></Textarea>

<input type=submit value="Submit Form!">

[ Click the submit button twice to see the script in action ]
</pre>
</form>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com";>The JavaScript Source</a></font>
</center><p>

<!-- Script Size:  2.05 KB -->

===================================================================================




<FORM METHOD="POST"  NAME='SubmitPage' ACTION="<@CGI><@APPFILE>?_function=finish">
<INPUT TYPE=SUBMIT NAME="Submit" VALUE="Submit Comment" onClick="return 
submitForm(document.SubmitPage, this, document.EditPage.Submit)"></p>

<!-- *************** SUBMIT WAIT ********************* -->

//script from http://www.rgagnon.com/jsdetails/js-0110.html
//modified 03052004 by Jamileh Wilcox

 var submitDone = false;
 
 function submitForm(myForm, button, OtherButton) {

      if (!submitDone) {
         submitDone = true;
         button.value = 'Please Wait';
         button.disabled = true;
         OtherButton.disabled = true;
         myForm.submit();
      } 
      else {
        alert ("Already submitted, please wait!");
      }
   return true;
 }

<!-- ************END SUBMIT WAIT ********************* -->

Reply via email to