Jump to content

Disabling submit button but still submit


smc

Recommended Posts

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

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> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.