473,796 Members | 2,512 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help disabling a submit button onClick

5 New Member
Hello, first time posting on thescripts.com, and I'm in dire need of some help.
All I want to do is disable the submit button (not the entire form) onClick, and am wondering if this is possible.

Here's the current coding:
Expand|Select|Wrap|Line Numbers
  1. <form enctype="multipart/form-data" action="?id=completeupload" name="submitform" method="POST">
  2. <b>File to Upload:</b>&nbsp;<input name="userfile" size="50" type="file"><br><br>
  3. <span class="class3">
  4. <input type="checkbox" name="agree" value="22">I agree to the upload terms and conditions for mysite.com (<a href='agreement.php' target='_blank'>&nbsp;View Terms&nbsp;</a>)<br><br>
  5. <input type="submit" value="Upload File" name="uploadbutton" onclick="submitform.disabled=true; submitform.form.submit();">
  6. </font></span>
  7. </form>
It's a file upload script, everything works other then when i try to disable the button onclick. With this current coding in IE it disables the entire form and doesn't process the request. FireFox it processes the request, but doesn't disable the button or form.

If anybody can help it would be greatly appreciated, thanks.
Feb 27 '08 #1
9 7148
eWish
971 Recognized Expert Contributor
If you are wanting to do away with the JavaScript function 'onclick', then simply delete the code for it.

Expand|Select|Wrap|Line Numbers
  1. onclick="submitform.disabled=true; submitform.form.submit();"
--Kevin
Feb 27 '08 #2
poml
5 New Member
Thanks for the quick reply ewish, still not working. I'm kind of new to this coding.

i found a new code of disabling the button onClick

onclick="docume nt.submitform.s ubmitbutton.dis abled=true;
document.submit form.mode.name = 'post';
document.submit form.onsubmit() ;
document.submit form.submit();"

Cool thing is is this works just fine in firefox, disables the button and then processes upload.php to upload the selected file. Only problem is in IE it just disables the button and doesn't process upload.php.
Feb 27 '08 #3
eWish
971 Recognized Expert Contributor
I guess that I don't understand. Do you want the data from the form to be sent to your php script? If so, would that not require the submit button? If not, then what is the purpose of the submit button in the first place? How else will you know that the user is done filling out the form and ready for processing if you don't use the button?

--Kevin
Feb 27 '08 #4
poml
5 New Member
Here, ...

If you try it in IE, the button is just disabled and it doesn't process

If you try it in FireFox, it disables it and uploads the file just fine

All I want is it for the submit button to be disabled in firefox and ie and goto the upload.php script. As far is checking the filesize, terms of agreement, all that works fine. If the user has inputed a valid file and accepted the terms of agreement, i just want Upload File submit button to be disabled to prevent anxious users from constantly clicking it.

Sorry for the confusion, I'm not good with explaining things.
Feb 27 '08 #5
drhowarddrfine
7,435 Recognized Expert Expert
You'll get better javascript answers from the javascript forum. I'll send this there.
Feb 27 '08 #6
poml
5 New Member
No need, I finally figured it out. Thank you very much though, this can get mighty frustrating at times. I appreciate it.
Feb 27 '08 #7
ronverdonk
4,258 Recognized Expert Specialist
No need, I finally figured it out. Thank you very much though, this can get mighty frustrating at times. I appreciate it.
Do you want to share your solution with our members in this forum? Thanks.

Ronald
Feb 29 '08 #8
poml
5 New Member
Do you want to share your solution with our members in this forum? Thanks.

Ronald
Definately, onClick this disables the Submit button within a Form and changes the caption to 'One Moment Please...' (works in IE and FireFox)

[HTML]<form enctype="multip art/form-data" action="upload. php" name="submitfor m" id="submitform " method="POST">
<b>File to Upload:</b>&nbsp;<input name="userfile" size="50" type="file"><br ><br>
<input type="submit" value="Upload" name="submitbut ton" onclick="docume nt.submitform.s ubmitbutton.val ue='One Moment Please...'; document.submit form.submitbutt on.disabled=tru e; document.submit form.submit();" >
</form>[/HTML]
Mar 2 '08 #9
acoder
16,027 Recognized Expert Moderator MVP
Definately, onClick this disables the Submit button within a Form and changes the caption to 'One Moment Please...' (works in IE and FireFox)
Thanks for posting your solution, but please remember to use code tags when posting code. Thanks!
Mar 2 '08 #10

Sign in to post your reply or Sign up for a free account.

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...
4
4941
by: gimme_this_gimme_that | last post by:
Hi, This is sort of a : How to build a Yes/No dialog box qquestion. Or perhaps a question about getting javascript variables from a pop-up window and processing them on a submit. This is what I'd like to have happen :
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!
4
5591
by: Dmitry Korolyov [MVP] | last post by:
When we use btnSubmit.Attributes = "javascript: this.disabled=true;" to make the button disabled and prevent users from clicking it again while form data still posting, there is no longer postback. I.e. the button does go disabled, but the form does not invoke submit() method. Of course, it does work fine without this property. Clues?
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
13104
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...
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 ?
8
12102
by: Willie | last post by:
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 :
1
2251
by: arggg | last post by:
I created a submit form that calls a javascript:AjAX Command that will call the data and submit it without have the page refresh. This works perfect in Firefox however in IE and Opera when the submit button is pressed it just disables the button and does not submit the data. Any idea? <script type="text/javascript" src="<?=$config->getKey('Site_URL')."js/AJAX.js"?>"></script> <form name="EditUser" method="post" accept="text/plain"...
0
9525
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10452
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...
1
10169
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
10003
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...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
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
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.