ruff_neck_chike
07-29-2005, 02:21 PM
I would like to find a way to disable a submit button after it is clicked so it can only be clicked once. I have found plenty of ways to do it java but i would rather use asp.
|
Click to See Complete Forum and Search --> : Submit Button ruff_neck_chike 07-29-2005, 02:21 PM I would like to find a way to disable a submit button after it is clicked so it can only be clicked once. I have found plenty of ways to do it java but i would rather use asp. buntine 07-29-2005, 09:42 PM That is not possible in ASP. ASP runs from the server, it has no way of comunicating, triggering, or catching events from the client-side. Java cannot do it either. You need JavaScript (which is not Java). Regards, Andrew Buntine. Adamal 08-03-2005, 05:11 PM There are several ways of accomplishing this, some more effective than others. One way (as you've noted) is to use client-side Javascript: <input type="submit" name="Action" value="Submit" onclick="this.disabled=true;this.form.submit();" /> Note: The submit button will only be disabled if Javascript is enabled in the client-browser, and also the button's "Action" key/value pair WILL NOT be sent in the form's data. Another way is to issue a "Response.Redirect" from the server after processing the form data to prevent the data from being posted twice. Of course, this only works if the request-response is quick enough that the user doesn't have time to click on the button again before the page is redrawn in the browser. You can also emit some HTML to the client and flush the Response buffer so that the browser can render something while you're still processing the data: <html> <body> <p>Processing data...</p> <%Response.Flush()%> A clever way of handling this is to assign a "hidden" form field with a unique ID, and submit this to your database (or wherever you're storing the form data). If the form is posted twice (i.e. the button is clicked more than once, or the user "refreshes" their browser window), you can check to see if this ID has been used already. If it hasn't, you'd add the form data to your database. If it has been used, you can either choose to ignore the posted data (an acceptible approach), or warn the user that they've tried to submit the data twice (best approach). ~Adamal webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |