How to avoid press button again

A

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?
 
A

Arjen

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
 
G

Guest

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
 
S

sreejith.ram

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);
 
J

jasonkester

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top