473,386 Members | 1,830 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,386 software developers and data experts.

Need help disabling a submit button onClick

5
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 7125
eWish
971 Expert 512MB
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
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="document.submitform.submitbutton.disabled =true;
document.submitform.mode.name = 'post';
document.submitform.onsubmit();
document.submitform.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 Expert 512MB
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
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 Expert 4TB
You'll get better javascript answers from the javascript forum. I'll send this there.
Feb 27 '08 #6
poml
5
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 Expert 4TB
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
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="multipart/form-data" action="upload.php" name="submitform" 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="submitbutton" onclick="document.submitform.submitbutton.value='O ne Moment Please...'; document.submitform.submitbutton.disabled=true; document.submitform.submit();">
</form>[/HTML]
Mar 2 '08 #9
acoder
16,027 Expert Mod 8TB
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
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
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...
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...
4
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...
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...
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 ?
8
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"...
1
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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...

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.