473,387 Members | 1,364 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,387 software developers and data experts.

Disable Submit Button

I have a payment form with a submit button. A large percentage of users
double-click the submit button thus submitting their payment information
twice. I would like to use javascript to disable the submit button once
it's been clicked, yet still have the form submit. I can do this in ASP
2.0, however, ASP.Net seems to be adversely affected if you disable the
submit button. Here's how I have it set up...

The submit button is a WebControls.Button
In the Page_Load event I attach an "onclick" javascript event handler to
disable the submit button.

i.e. btnSubmit.Attributes.Add("onclick", "document.Form1.btnSubmit.disabled
= true; return true;")

The problem with this is once the button is disable the form will not
submit. If I change it to the following it will work, however, the button
will not be disabled.

i.e. btnSubmit.Attributes.Add("onclick", "document.Form1.btnSubmit.disabled
= false; return true;")

Any ideas on how to accomplish this?

Thanks!
Nov 18 '05 #1
3 3128
Check out this, in the Tips & Tricks section of http://aspnet101.com:
http://aspnet101.com/aspnet101/tips.aspx?id=81

David Wier
MCP, MVP ASP.NET, ASPInsider
http://aspnet101.com
http://aspexpress.com
"Jeff" <a@a.com> wrote in message
news:Os****************@TK2MSFTNGP12.phx.gbl...
I have a payment form with a submit button. A large percentage of users
double-click the submit button thus submitting their payment information
twice. I would like to use javascript to disable the submit button once
it's been clicked, yet still have the form submit. I can do this in ASP
2.0, however, ASP.Net seems to be adversely affected if you disable the
submit button. Here's how I have it set up...

The submit button is a WebControls.Button
In the Page_Load event I attach an "onclick" javascript event handler to
disable the submit button.

i.e. btnSubmit.Attributes.Add("onclick", "document.Form1.btnSubmit.disabled = true; return true;")

The problem with this is once the button is disable the form will not
submit. If I change it to the following it will work, however, the button
will not be disabled.

i.e. btnSubmit.Attributes.Add("onclick", "document.Form1.btnSubmit.disabled = false; return true;")

Any ideas on how to accomplish this?

Thanks!

Nov 18 '05 #2
btnSubmit.Attributes.Add("onclick",
"window.setTimeout('document.Form1.btnSubmit.disab led= true;',10);");

but this recommend. the submit fails (post lost on internet), the user can
not refire it. if they hit refresh, the button will be enabled. you should
store a transaction guid in a hidden field and tack that it has been
processed. you should also code for two running at the same time.

-- bruce (sqlwork.com)
"Jeff" <a@a.com> wrote in message
news:Os****************@TK2MSFTNGP12.phx.gbl...
I have a payment form with a submit button. A large percentage of users
double-click the submit button thus submitting their payment information
twice. I would like to use javascript to disable the submit button once
it's been clicked, yet still have the form submit. I can do this in ASP
2.0, however, ASP.Net seems to be adversely affected if you disable the
submit button. Here's how I have it set up...

The submit button is a WebControls.Button
In the Page_Load event I attach an "onclick" javascript event handler to
disable the submit button.

i.e. btnSubmit.Attributes.Add("onclick", "document.Form1.btnSubmit.disabled = true; return true;")

The problem with this is once the button is disable the form will not
submit. If I change it to the following it will work, however, the button
will not be disabled.

i.e. btnSubmit.Attributes.Add("onclick", "document.Form1.btnSubmit.disabled = false; return true;")

Any ideas on how to accomplish this?

Thanks!

Nov 18 '05 #3
Hi Jeff,

Have you had a chance to check the other member's suggestions and resources
or have you got any further ideas on this issue? If you have any other
questions, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4

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

Similar topics

1
by: Paul Oakfleet | last post by:
The script below will disable Submit button until user accept terms, and will redirect user to another page after clicking on Submit button. The script seems to work fine on my PC (Windows XP,...
14
by: Sinity | last post by:
Anyone knows the method/codes to disable the clicked button after first click by using .aspx-- to prevent people to click many time when waiting for the server response. I tried to do this by...
6
by: GD | last post by:
Hi, I wonder how to disable the "submit" behavior of a button. What I want is to assign values to dynamically added user controls without page postback. Problem: dynamically created control can...
2
by: Ghafran Abbas | last post by:
Call this function from the Page_OnLoad event of your asp.net page. This will prevent the user from doing multiple post backs or button clicks. This was designed to not disable the button, because...
6
by: jack-e | last post by:
Hi, Can someone please provide me with an example of how to disable the submit button once clicked (using javascript i guess). Keep in mind I also have to invoke a server side function which...
16
by: Barry Gilmore | last post by:
Is there a way to disable a button after it is clicked? I am trying to avoid having someone click on it twice while they wait for it to process. Thank you!
4
by: Patrick Flaherty | last post by:
Hi, Experienced programmer but new to PHP. Moreover I'm to use PHP with Xoops on top (this adds object orientation?). I don't seem to find a xoops Usenet group? Whatever the case (and...
6
by: millw0rm | last post by:
i got a form full of radio buttons appx. 60-70, depends on the page. Some times 60, sometimes 55.... After certain period of time, i want to disable or make readonly all the radio button inside the...
5
by: andersond | last post by:
I need to enable or disable a submit button based on the value of a data field stored in a database. I have found working examples of how to enable or disable based on a checkbox; but, I need it to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.