smc Posted February 17, 2007 Share Posted February 17, 2007 Heya, Basically I have a picture upload along with my story submission on my news CMS. I would like to disable the submit button after they press it but when I use: onclick="this.disabled=true;" It disables the button but the page never submits to the PHP. Also, if possible, I would like it to change it's value to "Submitting" when the button is pressed and disabled. Thanks for any help you can offer!!!!! Link to comment https://forums.phpfreaks.com/topic/38939-disabling-submit-button-but-still-submit/ Share on other sites More sharing options...
sspoke Posted February 17, 2007 Share Posted February 17, 2007 you would have to use javascript to disable the submit button on a keypress event found a example javascript: function disableSubmit(whichButton) { if (document.getElementById) { // this is the way the standards work document.getElementById(whichButton).disabled = true; } else if (document.all) { // this is the way old msie versions work document.all[whichButton].disabled = true; } else if (document.layers) { // this is the way nn4 works document.layers[whichButton].disabled = true; } } how to use <form method="post" action="submitpause.php" onsubmit="javascript:disableSubmit('mFormSubmit')"> <table> <tr> <td>Name:</td> <td><input type="text" name="name" /></td> </tr> <tr> <td>Email:</td> <td><input type="text" name="email" /></td> </tr> <tr> <td>Message:</td> <td><textarea name="message" rows="4" cols="30"></textarea></td> </tr> <tr> <td colspan="2" style="text-align: center"> <input type="submit" name="submit" id="mFormSubmit" value="Send Message" /> </td> </tr> </table> </form> Link to comment https://forums.phpfreaks.com/topic/38939-disabling-submit-button-but-still-submit/#findComment-187306 Share on other sites More sharing options...
smc Posted February 17, 2007 Author Share Posted February 17, 2007 It disables the button but doesn't submit the page, it just reloads it and takes no form action Link to comment https://forums.phpfreaks.com/topic/38939-disabling-submit-button-but-still-submit/#findComment-187323 Share on other sites More sharing options...
sspoke Posted February 17, 2007 Share Posted February 17, 2007 that example submits for me I tested it http://www.netlobo.com/disable_form_buttons.html here is the demo Link to comment https://forums.phpfreaks.com/topic/38939-disabling-submit-button-but-still-submit/#findComment-187324 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.