473,799 Members | 3,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.d isabled=true;th is.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 12102
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.d isabled=true;th is.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.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 10 '07 #2

"Willie" <wi****@pdfsyst ems.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.d isabled=true;th is.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...@pdfsyst ems.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.d isabled=true;th is.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.f orm.submit();th is.disabled=tru e;return false' >

OR

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


Jul 15 '07 #4
On Jul 15, 5:57 pm, "scripts.contac t" <scripts.cont.. .@gmail.com>
wrote:
On Jul 10, 2:36 pm, "Willie" <wil...@pdfsyst ems.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.d isabled=true;th is.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.f orm.submit();th is.disabled=tru e;return false' >

OR

<form ... onsubmit="this. return1.disable d=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.javas cript:
><form ... onsubmit="this. return1.disable d=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.net wrote:
David Mark wrote on 16 jul 2007 in comp.lang.javas cript:
<form ... onsubmit="this. return1.disable d=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.javas cript:
On Jul 16, 5:18 pm, "Evertjan." <exjxw.hannivo. ..@interxnl.net wrote:
>David Mark wrote on 16 jul 2007 in comp.lang.javas cript:
><form ... onsubmit="this. return1.disable d=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.net wrote in message
news:Xn******** ************@19 4.109.133.242.. .
David Mark wrote on 16 jul 2007 in comp.lang.javas cript:
>On Jul 16, 5:18 pm, "Evertjan." <exjxw.hannivo. ..@interxnl.net wrote:
>>David Mark wrote on 16 jul 2007 in comp.lang.javas cript:

<form ... onsubmit="this. return1.disable d=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
2063
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
11401
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 4.5 and a good deal of the page processing depends on whether or not a control is defined. To prevent users from clicking on a submit button more than once or clicking on another submit button before the page has finished processing I have...
15
28959
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="..." value="..."> with <input type="submit" ...> the only name-value values submitted (pushed into the query string) is the one of the submit button that was pushed (if you have many of them). Ex:
2
7796
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 button only once (viz. he should not be allowed to submit the form twice). This stuff is easy when using a ASP:Button or HTML Button... but a link button has got me wondering how... plz help!
2
1381
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 around one minute. I want to disable the button after the user clicks on it so that he cannot click it again while the processing is going on. But when I do this using javascript, the button is getting disabled while the form is not getting...
3
13105
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 disable the button in the OnClick event in ASP.Net because then the Click event won't post to the server (because you disabled it). I searched google groups, and there is a solution to this problem, but I didn't think it was clean enough and...
10
6092
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 different results than when I use a javascript submit: form1.submit();. I think the javascript submit is working as it should, since I want the server to process an __EVENTTARGET posting. When I click the submit button, it does not process the...
5
2059
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
5515
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 call a form's submit. I've found how to post programatically, but I need to use the form's target attribute so that the response goes into another frame, and I can't figure out how to do that programatically.
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10484
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10228
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.