470,619 Members | 1,437 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,619 developers. It's quick & easy.

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 6885
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

Post your reply

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

Similar topics

16 posts views Thread by Ralph Freshour | last post: by
2 posts views Thread by Jeelz | last post: by
4 posts views Thread by Dmitry Korolyov [MVP] | last post: by
2 posts views Thread by Srinivas | last post: by
5 posts views Thread by Joja | last post: by
8 posts views Thread by Willie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.