Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double posting on my database

Status
Not open for further replies.

DarkMan

Programmer
Apr 13, 1998
222
US
I've been having a problem on my website with people clicking a submit button more than once. When they do this, my form handling routine submits the info to the database more than once. In MSIE, I've been able to avoid this by making the button disappear with an onclick javascript, but this doesn't work in Netscape Navigator. Is there any way to avoid this that will work in both browsers? I am using Microsoft SQL Server and Allaire Cold Fusion.
 
I don't pretend to be an expert in javascrip, in fact I am very

much a novice and probably couldn't answer any questions at

this point. I do have this suggestion however,

you say you want your "onclick" to work in both

MSIE and Netscape. The following is from "Designing with Javascript" by Nick Heinle and may be useful to you, basically stating that if

the browser is Netscape 3.0 or greater "and" MSIE 4.0 and greater

to render the script as written.



bName = navigator.appName;

bVer = parseInt(navigator.appVersion);

if ((bName == "Netscape" && bVer ›= 3) ¦¦

(bName == "Microsoft Internet Explorer" && bVer ›=4)) br = "n3";

else br = "n2";



if (br == "n3") {



Then include the rest of your script....hope it helps.
 
Somehow this threadminder has transposed my "greater than" characters as comma's. Keep this in mind when using Nick Heinle's

quoted script portion.
 
goto Allaire Tag gallery and download one of <br>
those free tags from other developers.<br>
<br>
there is one that 'after clicking, ' it will<br>
shows another message on the button...<br>
<br>
this should help reduce the number of people<br>
douoble clicking.<br>
<br>

 
Here's a quick script that should do the WHOLE job for you:<br>
put the following JavaScriptlet in a function; then call the function using an onClick attached to the submit button:<br>
<br>
if imclicked != yes<br>
{<br>
imclicked=yes;<br>
return true;<br>
}else{<br>
alert("Please Wait for form submission to complete")<br>
return false;<br>
}<br>
<br>
and put the folowing scriptlet between the &lt;head&gt; and &lt;/head&gt; tags in your source:<br>
<br>
&lt;script language=JavaScript&gt;<br>
&lt;!--<br>
var imclicked;<br>
//--&gt;<br>
&lt;/script&gt;<br>
<br>
<br>
that SHOULD be all you need, but please feel free to cantact me if it doesn't work.<br>
<br>
-Robherc<br>
robherc@netzero.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top