Forum Moderators: open

Message Too Old, No Replies

Tryin to find a way to stop multiple submits

user is impatient and hammers on the submit button

         

mikejson

7:06 pm on Dec 2, 2003 (gmt 0)

10+ Year Member



Any thoughts? I posted in the javascript board and nothing yet. Is there a simple HTML way to do this? any thought on how to do it any other way?

lorax

7:10 pm on Dec 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



on form.submit use Javascript to hide the Submit button and put up a "Please be patient" notice?

mikejson

7:30 pm on Dec 2, 2003 (gmt 0)

10+ Year Member



I did try something like that, changing the text on the button to "Wait..." but for some reason I couldn't call the validate function as well as the submit/change text function onSubmit...

It would error out on the page and ask to debug, I looked at the debug and my syntax was wrong in the onSubmit.

How do you call multiple javascript functions in the onSubmit of the form tag? Can you put a expression in there?

ie.
<form ... onSubmit=" 'return Validate(form)'&&'return changeButton(form)'... >

Assuming that both functions return something and they both take those arguments and do something...

I've never had the need to do that before so I don't know. Or is there a different way? I feel as I'm thinkin 1-dimensionally right now... been a long week already ...sigh....

lorax

8:25 pm on Dec 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You've got me there. I know only enough javascript to be dangerous. You'd be better off posting in the Javascript forum for the answer. Sorry.

DrDoc

8:30 pm on Dec 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Call only one function, and let that function call the other...

mikejson

9:27 pm on Dec 2, 2003 (gmt 0)

10+ Year Member



hehe, yup I thought of that after I started programming it... works like a charm now... thanks guys

MatthewHSE

10:14 pm on Dec 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad you found a solution for this; one that I'll probably try to implement myself. However, I don't think there's a way to actually, completely, eliminate multiple form submissions. My form loads a new page upon successful submission. Only successful submissions are e-mailed to me (they're also added to a .csv database). And I often get users who, confirmation page and all, still submit the form twice or more.

DrDoc

11:44 pm on Dec 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can eliminate duplicates, but only through some form of logic on the server side.

GaryK

11:53 pm on Dec 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's my technique. I set a variable in JS called something like submitClicked that initially is false. Once someone clicks what looks like a submit button, but is really just a button, I call a JS function that first checks if submitClicked is false. If it is false I set submitClicked to true and the form gets submitted. If someone clicks on the submit button again and submitClicked is true I skip over the code that re-submits the form.

DrDoc

4:39 am on Dec 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



..and if the user has JavaScript turned off? Then the form will be submitted over and over again...

Krapulator

4:46 am on Dec 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A combination of client-side js (Ive got a good script-if you want it - sticky me) and server-side detection is the best overall solution.

mikejson

1:46 pm on Dec 3, 2003 (gmt 0)

10+ Year Member



I was thinking of just using a flat-file to stop multiple submits(after initially stopping the mad click submits). What I was thinking, since my form collects information that is unique to each individual that submits my form I can then store that value(it's a number) in a file, and search that file everytime someone submits. Only problem with that, is this form is being used by thousands of people within a short period of time(about 3000 people in a 2 month span, usually between 1pm-7pm). This might cause some problems. I don't really feel like setting up a program to submit repeatedly to try and test it... so I probably won't implement the idea.

killroy

2:08 pm on Dec 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I tried:
onsubmit="this.submit.disabled=true;this.submit.value='One Moment Please...'"

and it seems to work well enough...

SN

mikejson

3:15 pm on Dec 3, 2003 (gmt 0)

10+ Year Member



Could you confirm this as I will be testing it but I want to know for sure

This submits once, then changes the name of the button and doesn't do anything else?

Thanks a ton.

Oh and how would I call the verify form function I am already calling onSubmit?

mikejson

3:24 pm on Dec 3, 2003 (gmt 0)

10+ Year Member



I just tried what you said, didn't work, I have javascript enabled too...

Stretch

3:41 pm on Dec 3, 2003 (gmt 0)

10+ Year Member



What about...

<input type="submit" value="Go &gt;&gt;" name="go" onClick="if(this.value == 'Go &gt;&gt;') this.form.submit(); this.value = 'Wait...'; this.disabled = true;">

GaryK

5:19 pm on Dec 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



..and if the user has JavaScript turned off? Then the form will be submitted over and over again...

DrDoc, that's why I also use server side code to deal with this issue. I didn't mention it here because the topic seemed to deal with JS.

Once the form is submitted and I'm on the server-side of things I store the text in a holding area. If the user tries to post the same message again I reject it as spam.