[thelist] Submitting contents of form only once

Bret Daniel BDaniel at Chemnavigator.com
Fri Jan 5 17:46:12 CST 2001


This work with IE and Netscape <4.7x

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
// Web Site:  http://dynamicdrive.com
// This script and many more are available free online at
// The JavaScript Source!! http://javascript.internet.com
var DSsubmitcount=0;
function disableDupSubmit(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.type.toLowerCase() == "button")
				tempobj.disabled = true;
		}
		return true;
	}
	else {
   		if (DSsubmitcount == 0) {
			DSsubmitcount++;
			return true;
		}
		else 
			return false;
	}
}
// End -->
</SCRIPT>
IE the theform.elements[submit].disabled = true kills the button for the
form
Basically, once the Netscapers hit the submit button, it returns false,
which keeps the button from submitting


-----Original Message-----
From: Jon Hall [mailto:jonhall at ozline.net]
Sent: Friday, January 05, 2001 1:27 PM
To: thelist at lists.evolt.org
Subject: Re: [thelist] Submitting contents of form only once


Easiest but not foolproof is just to change the text of the button after
they have submitted :-)
 <INPUT TYPE="Button" NAME="Submit" VALUE="Submit"
onClick="if(this.value == 'Submit') this.form.submit(); this.value =
'Please Wait.';">

This only works in new browsers though
In your head put this
<script>
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>

call it like so..
<form method="POST" onSubmit="submitonce(this)">

jon

----- Original Message -----
From: "Ben Gustafson" <ben_gustafson at lionbridge.com>
To: <thelist at lists.evolt.org>
Sent: Friday, January 05, 2001 2:22 PM
Subject: [thelist] Submitting contents of form only once


> Does anyone know an easy way, using JavaScript and/or ASP, to make a form
be
> submitted only the first time a user clicks the Submit button? I'm doing a
> simple database insert with the contents of a form, and since it's a long
> form, users have a tendency to click the Submit button a few times.
>
> Thanks in advance for your help,
>
> --Ben Gustafson
>
>
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt !


---------------------------------------
For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt ! 




More information about the thelist mailing list