473,385 Members | 1,341 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.

How to avoid press button again

ad
I write a time-consuming process in a button's onclick event.
Some user may press the button again when the process is excuting.
How to avoid that?
Nov 19 '05 #1
4 1714
Hi,

Add this javascript:
<script type="text/javascript" language="javascript">
var submitted = 0;
function check_double_click(form) {
if (submitted == 1) {
alert("Hey, don't press again! Fool!!!");
return false;
}
submitted = 1;
return true;
}
</script>

Add this in your button
OnClientClick="check_double_click(this)"

Hope this helps,
Arjen

"ad" <ad@wfes.tcc.edu.tw> schreef in bericht
news:%2****************@TK2MSFTNGP12.phx.gbl...
I write a time-consuming process in a button's onclick event.
Some user may press the button again when the process is excuting.
How to avoid that?

Nov 19 '05 #2
Hi,

The simplest way is to add absolutely positioned div layer with a message
like “Your request is being processed” and show them when the request is
being processed. You can also hide processing button after user has clicked
it. See javascript/CSS reference for “visibility” and “disabled”. Please also
have a look at “onserverclick” “onclick” events for HtmlInputButton.

Regards

Milosz Skalecki

MCP, MCAD
"ad" wrote:
I write a time-consuming process in a button's onclick event.
Some user may press the button again when the process is excuting.
How to avoid that?

Nov 19 '05 #3
another simple method that works is to just disable the button onclick
....

function Button_click(objButton)
{
objButton.disabled = true;
return true;
}

add event
onclick=Button_click(this);

Nov 19 '05 #4
Note that these will only work on a browser with javascript enabled,
and in the case of the parent, only in IE. Unless you have complete
control over your user environment (i.e., intranet), you'll want to add
code on the server side to make sure that the inevitable multiple
submits get handled gracefully.

Unfortunately, the most common place that this issue comes up is the
one where you'll have the least control over your user's environment,
that being the Checkout button in an ecommerce application. In this
case, you'll also need to handle multiple submits on the server side
too, if only as a fallback for the odd user coming in on IE 3 for the
Macintosh, with Javascript disabled.

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #5

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

Similar topics

24
by: el_roachmeister | last post by:
Is there a way to make a text link post to a form without passing all the parameters in the url? The urls tend to get very long and messy. I often wonder if there is a limit to how long they can...
7
by: JCO | last post by:
How's come when I press the enter key, I can't get it to execute the correct password. It seems that I'm forced to press the button. I want to be able to do both. How is this done?
6
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many...
3
by: Shawn | last post by:
Hi. We have a web application that is used by several different companies. Each company have access to a couple of hundred records which they are updating daily. One of they companies have...
2
by: Priya | last post by:
Hi, I want to avoid the events being called when page is refreshed. For eg: I call a button event that modifies some data in the database. If i press F5 on the same page again the button event...
0
by: neeraj | last post by:
Hi Everybody I have one problem in my asp.net web application. The problem is that I check the date validation in code behind; if user not gives the valid data and press save button then I fire...
0
by: sat1582 | last post by:
I need avoid postback in a radio button control when press enter key, if you know how do this please tell me. Thanks for your response at sat1582@hotmail.com
2
by: Max2006 | last post by:
Hi, I have a simple form with a button on it. After a button click postback, anytime user press F5 (browser page refresh), the button's OnClick event handler is called again without the button...
1
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
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: 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: 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
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...

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.