473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Filtering or avoiding double click on form submission

Despite searching the net, I can't find a suitable solution that prevents a
user's double click from submitting a form twice. I'm currently using the
following in a button element:

<input type="button" onclick="this.disabled=true;this.form.submit();">

While it prevents multiple single clicks, it isn't good enough for a fast
double click, such as found on some multi-button mice.

Anyone have a better solution?

--
Ed Jay (remove 'M' to reply by email)

Win the War Against Breast Cancer.
Knowing the facts could save your life.
http://www.breastthermography.info
Oct 14 '08 #1
14 3358
On Oct 15, 12:01*am, Ed Jay wrote:
Despite searching the net, I can't find a suitable solution that preventsa
user's double click from submitting a form twice. I'm currently using the
following in a button element:
<input type="button" onclick="this.disabled=true;this.form.submit();">
While it prevents multiple single clicks, it isn't good enough for a fast
double click, such as found on some multi-button mice.
Have a look at
http://www.dynamicdrive.com/dynamici...submitonce.htm

I do not know if is fast enough for all mice,
and using cats would not be very nice.
Oct 14 '08 #2
Ed Jay wrote:
Despite searching the net, I can't find a suitable solution that prevents a
user's double click from submitting a form twice. I'm currently using the
following in a button element:

<input type="button" onclick="this.disabled=true;this.form.submit();">
Use a submit button and don't call this.form.submit();

<input type="button" onclick="this.disabled=true;">

This makes the form accessible when js is not enabled.

What happens when the user's connection drops after the user fills out
the form, but before pressing submit?

If you've used a wireless connection, you've no doubt run into that
problem. It's a bad effect that I remember experiencing on GG and GMail
many times.

Garrett

--
comp.lang.javascript FAQ <URL: http://jibbering.com/faq/ >
Oct 14 '08 #3
dhtml wrote:
Ed Jay wrote:
>Despite searching the net, I can't find a suitable solution that
prevents a
user's double click from submitting a form twice. I'm currently using the
following in a button element:

<input type="button" onclick="this.disabled=true;this.form.submit();">

Use a submit button and don't call this.form.submit();

<input type="button" onclick="this.disabled=true;">
I meant:

<input type="submit" onclick="this.disabled=true;">
This makes the form accessible when js is not enabled.

What happens when the user's connection drops after the user fills out
the form, but before pressing submit?

If you've used a wireless connection, you've no doubt run into that
problem. It's a bad effect that I remember experiencing on GG and GMail
many times.
So can be replaced with:
<input type="submit">

If you need to filter double requests on the server, put a hidden in the
form. When the token comes, you've got your request. Subsequent
submissions with that token can be ignored.

Garrett
Garrett

--
comp.lang.javascript FAQ <URL: http://jibbering.com/faq/ >
Oct 14 '08 #4
my*******************@googlemail.com scribed:
>On Oct 15, 12:01*am, Ed Jay wrote:
>Despite searching the net, I can't find a suitable solution that prevents a
user's double click from submitting a form twice. I'm currently using the
following in a button element:
<input type="button" onclick="this.disabled=true;this.form.submit();">
While it prevents multiple single clicks, it isn't good enough for a fast
double click, such as found on some multi-button mice.

Have a look at
http://www.dynamicdrive.com/dynamici...submitonce.htm

I do not know if is fast enough for all mice,
and using cats would not be very nice.
Thanks. Tried it, and it failed.

--
Ed Jay (remove 'M' to reply by email)

Win the War Against Breast Cancer.
Knowing the facts could save your life.
http://www.breastthermography.info
Oct 14 '08 #5
dhtml scribed:
>Ed Jay wrote:
>Despite searching the net, I can't find a suitable solution that prevents a
user's double click from submitting a form twice. I'm currently using the
following in a button element:

<input type="button" onclick="this.disabled=true;this.form.submit();">
Use a submit button and don't call this.form.submit();

<input type="button" onclick="this.disabled=true;">

This makes the form accessible when js is not enabled.
Not a problem with js disabled, as the user cannot access the form unless js
is enabled.
>
What happens when the user's connection drops after the user fills out
the form, but before pressing submit?

If you've used a wireless connection, you've no doubt run into that
problem. It's a bad effect that I remember experiencing on GG and GMail
many times.
Good point, in general, but this is a web app in a doctor's office, so
losing a wireless connection doesn't pose a problem.

--
Ed Jay (remove 'M' to reply by email)

Win the War Against Breast Cancer.
Knowing the facts could save your life.
http://www.breastthermography.info
Oct 15 '08 #6
rf

"dhtml" <dh**********@gmail.comwrote in message
news:gd**********@registered.motzarella.org...
dhtml wrote:
>Ed Jay wrote:
>>Despite searching the net, I can't find a suitable solution that
prevents a
user's double click from submitting a form twice. I'm currently using
the
following in a button element:

<input type="button" onclick="this.disabled=true;this.form.submit();">

Use a submit button and don't call this.form.submit();
If you need to filter double requests on the server, put a hidden in the
form. When the token comes, you've got your request. Subsequent
submissions with that token can be ignored.
Or cause the server side script to issue a redirect to a "thankyou" page.
This can be extended to representing (without processing) the form page when
you find invalid values.
Oct 15 '08 #7
Ed Jay wrote:
Despite searching the net, I can't find a suitable solution that
prevents a user's double click from submitting a form twice. I'm
currently using the following in a button element:

<input type="button" onclick="this.disabled=true;this.form.submit();">

While it prevents multiple single clicks, it isn't good enough for a
fast double click, such as found on some multi-button mice.

Anyone have a better solution?
The only and best way to ensure this isn't an issue, is coding the
script to only execute the necessary functions on the first click. All
of the logic must be done in the script, and it's always best to code
scripts to not create a problem if a user was to submit the form over
once. Things like JavaScript on the browser end probably won't hurt,
but shouldn't be relied upon. Use some custom session instead and
control what happens and anticipate the things such as a double
submission.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
Oct 15 '08 #8
dhtml scribed:
>>Despite searching the net, I can't find a suitable solution that
prevents a user's double click from submitting a form twice. I'm currently using the
following in a button element:
If you need to filter double requests on the server, put a hidden in the
form. When the token comes, you've got your request. Subsequent
submissions with that token can be ignored.
Doesn't thin presuppose that the same instance of the script is running for
both submissions?

--
Ed Jay (remove 'M' to reply by email)

Win the War Against Breast Cancer.
Knowing the facts could save your life.
http://www.breastthermography.info
Oct 15 '08 #9
Ed Jay wrote:
<input type="button" onclick="this.disabled=true;this.form.submit();">

While it prevents multiple single clicks, it isn't good enough for a fast
double click, such as found on some multi-button mice.

Anyone have a better solution?
Caveat: I'm a Javascript novice.

Can you change your <inputso that it does a submit from the "onclick"
handler? The code that does the submit could then ignore a second click.

In concept:

onload sets come counter to 0
onclick increments the counter, and submits the form iff counter=1
--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Oct 15 '08 #10
Ed Jay wrote:
dhtml scribed:
>Ed Jay wrote:
Good point, in general, but this is a web app in a doctor's office, so
losing a wireless connection doesn't pose a problem.
There are three things wrong with that statement.

1) It precludes the possibility that a doctors' office could use wifi.
2) It ignores the possibility of the connection being disconnected for
another reason.
3) It's medicine related. When the script fails, the doctor will have to
resort to some other means of performing his task.

Making the doctor rely on your web script is a bad idea.

Garrett
--
comp.lang.javascript FAQ <URL: http://jibbering.com/faq/ >
Oct 15 '08 #11
rf

"dhtml" <dh**********@gmail.comwrote in message
news:gd**********@registered.motzarella.org...
2) It ignores the possibility of the connection being disconnected for
another reason.
Cleaners.

Cleaners inviarably pull out and clean up that messy blue wire thingy
hanging out the back of the cupboard.
Oct 15 '08 #12
rf scribed:
>
"dhtml" <dh**********@gmail.comwrote in message
news:gd**********@registered.motzarella.org...
>2) It ignores the possibility of the connection being disconnected for
another reason.

Cleaners.

Cleaners inviarably pull out and clean up that messy blue wire thingy
hanging out the back of the cupboard.
You folks may well be correct. Perhaps when I've solved the issue I posted
about, I'll look into the possibility of interrupted service issues. Thanks.

--
Ed Jay (remove 'M' to reply by email)

Win the War Against Breast Cancer.
Knowing the facts could save your life.
http://www.breastthermography.info
Oct 15 '08 #13
dhtml wrote:
Ed Jay wrote:
>Despite searching the net, I can't find a suitable solution that
prevents a user's double click from submitting a form twice. I'm
currently using the following in a button element:

<input type="button" onclick="this.disabled=true;this.form.submit();">

Use a submit button and don't call this.form.submit();

<input type="button" onclick="this.disabled=true;">

This makes the form accessible when js is not enabled.
That is a) no submit button (type="submit" was), and b) would it make the
form unsubmittable when returning to it using the Back feature of UAs. So
much for accessibility.

The proper and oft-recommended solution is to let a server-session expire
after the submit, and to check then whether the session expired before doing
anything else.
F'up2 comp.infosystems.www.authoring.misc

PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Oct 15 '08 #14
rf wrote:
"dhtml" wrote:
>If you need to filter double requests on the server, put a hidden in the
form. When the token comes, you've got your request. Subsequent
submissions with that token can be ignored.

Or cause the server side script to issue a redirect to a "thankyou" page.
This can be extended to representing (without processing) the form page when
you find invalid values.
Since the "thank you" "page" cannot reasonably be displayed before the
server has finished, and the user might try to submit again in the meantime,
this is no solution at all.

Please fix your From header so that it complies with Internet Standards and
Netiquette.
F'up2 c.i.w.a.m

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Oct 15 '08 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Display Name | last post by:
the customer I'm developing a site for uses a canned form-parsing page that allows her to have an email subscription opt-in page add emails to a list she can manage using a link that you point your...
4
by: jfancy-Transport Canada | last post by:
Hi, I'm looking for an asp page to detect if there are any characters in my contact form that shouldn't be there. For example, if there is a "<" character, then this may mean there is html in my...
19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
2
by: Sean | last post by:
Greetings all, I am attempting to make a form that will filter through several tables that (I believe) have refretial integrity. I am pulling data from several tables into the form and i would...
1
by: mstery | last post by:
I have a report generated via an ID selection made in a dropdown on a form. The report filters by an on click event in a preview report button on the form. Everything in the report, including...
0
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a...
7
by: theyas | last post by:
How can I get my code to NOT display two "Open/Save/Cancel/More Info" dialog boxes when using the "Response.WriteFile" method to download a file to IE I've asked about this before and didn't get a...
1
by: DarthOptimus | last post by:
Hi, There is javascript code on my jsp to prevent double submission of a form: <SCRIPT type="text/javascript" language="JavaScript"> var firstSubmit = true; function isFirstSubmit() {
15
by: ABC | last post by:
Hi, I have a problem with Double submission in html forms. I am using PHP as the server side scripting language, i have found a means to capture the second form submission while the first form...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.