473,387 Members | 1,470 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.

disabling the submit button after click

Hi All;

I have a form with multiple buttons and I would like to disable the buttons
after the user clicks on the button to prevent multiple submitions.

<input type="submit" name="return1" value="Send To MFG" id="return1"
onClick='this.disabled=true;this.form.submit()' >

This works but I do not get the return1 value passed to the action script as
I do if I just have :

<input type="submit" name="return1" value="Send To MFG" id="return1" >

I need this vale to be know which button was pushed. Is there a way of
passing a value with the form.submit() ?

Thanks
Willie
Jul 10 '07 #1
8 12076
Willie said the following on 7/10/2007 4:36 PM:
Hi All;

I have a form with multiple buttons and I would like to disable the buttons
after the user clicks on the button to prevent multiple submitions.

<input type="submit" name="return1" value="Send To MFG" id="return1"
onClick='this.disabled=true;this.form.submit()' >

This works but I do not get the return1 value passed to the action script as
I do if I just have :

<input type="submit" name="return1" value="Send To MFG" id="return1" >

I need this vale to be know which button was pushed. Is there a way of
passing a value with the form.submit() ?
Simplest? Create a hidden input and submit that hidden input to the
server. And use the onsubmit event to set the hidden input's value to
the value of the submit button that was clicked.

Another solution: Cover it up with an overlaying div element that will
prevent multiple clicks.

Best solution: Educate your users to the problems with multiple submits.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 10 '07 #2

"Willie" <wi****@pdfsystems.comwrote in message
news:f7*********@news5.newsguy.com...
Hi All;

I have a form with multiple buttons and I would like to disable the
buttons after the user clicks on the button to prevent multiple
submitions.
Why? You need to handle that on the server as you can't count on
JavaScript.
>
<input type="submit" name="return1" value="Send To MFG" id="return1"
onClick='this.disabled=true;this.form.submit()' >

This works but I do not get the return1 value passed to the action script
as I do if I just have :

<input type="submit" name="return1" value="Send To MFG" id="return1" >
In the first example you disabled it and then submitted the form with
script. So of course the server has no idea which button was used for
submission (none were.)
>
I need this vale to be know which button was pushed. Is there a way of
passing a value with the form.submit() ?
Your second example is correct (but you shouldn't need the id attribute.)
If you must, you can add client-side code to hide all of the buttons when
one is clicked, but I wouldn't bother. You will still have the case of the
Enter key (assuming your form has text inputs), so just make sure your
server-side handler throws out duplicate posts.
>
Thanks
Willie

Jul 11 '07 #3
On Jul 10, 2:36 pm, "Willie" <wil...@pdfsystems.comwrote:
I have a form with multiple buttons and I would like to disable the buttons
after the user clicks on the button to prevent multiple submitions.

<input type="submit" name="return1" value="Send To MFG" id="return1"
onClick='this.disabled=true;this.form.submit()' >

This works but I do not get the return1 value passed to the action script

Disable it after submitting :
<input type="submit" name="return1" value="Send To MFG"
onClick='this.form.submit();this.disabled=true;ret urn false' >

OR

<form ... onsubmit="this.return1.disabled=1">
....
<input type="submit" name="return1">
</form>


Jul 15 '07 #4
On Jul 15, 5:57 pm, "scripts.contact" <scripts.cont...@gmail.com>
wrote:
On Jul 10, 2:36 pm, "Willie" <wil...@pdfsystems.comwrote:
I have a form with multiple buttons and I would like to disable the buttons
after the user clicks on the button to prevent multiple submitions.
<input type="submit" name="return1" value="Send To MFG" id="return1"
onClick='this.disabled=true;this.form.submit()' >
This works but I do not get the return1 value passed to the action script

Disable it after submitting :
<input type="submit" name="return1" value="Send To MFG"
onClick='this.form.submit();this.disabled=true;ret urn false' >

OR

<form ... onsubmit="this.return1.disabled=1">
...
<input type="submit" name="return1">
</form>
For some reason the OP wants to disable only one of the multiple
submit buttons, so the second example won't work.

Jul 16 '07 #5
David Mark wrote on 16 jul 2007 in comp.lang.javascript:
><form ... onsubmit="this.return1.disabled=1">
...
<input type="submit" name="return1">
</form>

For some reason the OP wants to disable only one of the multiple
submit buttons, so the second example won't work.
Why? I think it will.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 16 '07 #6
On Jul 16, 5:18 pm, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
David Mark wrote on 16 jul 2007 in comp.lang.javascript:
<form ... onsubmit="this.return1.disabled=1">
...
<input type="submit" name="return1">
</form>
For some reason the OP wants to disable only one of the multiple
submit buttons, so the second example won't work.

Why? I think it will.
You think it will do what? It will disable just the return1 button,
which may or may not be the one that was clicked.

Jul 16 '07 #7
David Mark wrote on 16 jul 2007 in comp.lang.javascript:
On Jul 16, 5:18 pm, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
>David Mark wrote on 16 jul 2007 in comp.lang.javascript:
><form ... onsubmit="this.return1.disabled=1">
...
<input type="submit" name="return1">
</form>
For some reason the OP wants to disable only one of the multiple
submit buttons, so the second example won't work.

Why? I think it will.

You think it will do what? It will disable just the return1 button,
which may or may not be the one that was clicked.
Yes, "OP wants to disable only one of the multiple submit buttons".

I think the whole idea is aweful.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 16 '07 #8

"Evertjan." <ex**************@interxnl.netwrote in message
news:Xn********************@194.109.133.242...
David Mark wrote on 16 jul 2007 in comp.lang.javascript:
>On Jul 16, 5:18 pm, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
>>David Mark wrote on 16 jul 2007 in comp.lang.javascript:

<form ... onsubmit="this.return1.disabled=1">
...
<input type="submit" name="return1">
</form>

For some reason the OP wants to disable only one of the multiple
submit buttons, so the second example won't work.

Why? I think it will.

You think it will do what? It will disable just the return1 button,
which may or may not be the one that was clicked.

Yes, "OP wants to disable only one of the multiple submit buttons".
The one that was clicked of course. Not the first "return1" every time.
>
I think the whole idea is aweful.
So do I. As I mentioned, duplicate submissions should be dealt with on the
server.
Jul 16 '07 #9

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

Similar topics

16
by: Ralph Freshour | last post by:
How can I disable a button once it has been clicked? I want to prevent the user from clicking on it twice if they have a slow connection. Thanks...
6
by: JSjones | last post by:
Hi all, I'm new to these boards and my javascript experience is fairly limited and basic so please bear with me. Anyway, on to the question and some background. I'm developing using ColdFusion...
15
by: Mattia | last post by:
Hi! I have a <form> that can be submitted thruogh three buttons and I need to tell witch one was pressed when the form was submitted. I now do it with 3 <input type="submit" name="..."...
2
by: Jeelz | last post by:
Hi Guyz, Would appriciate any tip on disabling an ASP.NET LinkButton using client sided code like javascript. My Requirement is such that the user should be allowed to click on the link...
2
by: Srinivas | last post by:
Hi, I have a webform with some dropdown menus, textboxes required and custom validators. I added a click event handler for the button in which there is code for processing. This processing takes...
3
by: Mark | last post by:
This is a solution... Often users want to keep clicking "submit" when they are waiting for server processing. Most apps these days like to disable the submit button to prevent this. You can't just...
10
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get...
5
by: Joja | last post by:
I have form with one submit button. All i want to create is to allow user to make JUST ONE button click. After that click, button will be still displayed but it will be disabled. How to make this ?
4
by: j1dopeman | last post by:
Hi, I'd like to use a button to save and then submit a form. I can set the onlick of the button to mahButton_click or submit, but I can't figure out how to do both. It looks like c# can't...
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: 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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.