Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make Submit Inactive

Status
Not open for further replies.

jlindahl

Programmer
Sep 23, 2003
46
0
0
US
Is there a way to make the submit button inactive once the user clicks on it? I am trying to prevent a user from clicking the submit button multiple times when the server is running slow.
 
this should do it for you:
Code:
<input type='submit' onClick='this.disabled = true'>


"Whether you think that you can, or that you can't, you are usually right." - Henry Ford
 
This is good ol' trick to prevent multiple posts. Something like:

Code:
<input type="submit" blah blah ... onclick="this.disabled=true;">
 
I'm pretty sure you have to return false on any onclick events for a submit button or it submits 2x.
Code:
<input type=submit value='click me' onclick='this.disabled=true;return false;'>

-kaht

banghead.gif
 
This is what I have now:
Code:
<input type='submit' name='Submit' value='Submit' onclick="value='Wait.. Processing Info..';">
I would like to keep the value change, but now include the disable feature. Now I've added this:
Code:
<input type='submit' name='Submit' value='Submit' onclick="value='Wait.. Processing Info..';this.disabled=true;">
Now when I submit the form, the value changes, the button is disabled, but the form does not get submitted.
 
You might try:

Code:
<input type='submit' name='Submit' value='Submit' onclick="value='Wait.. Processing Info..';this.disabled=true;[b]formName.submit();[/b]">

Good luck!

--Dave
 
Just for a note why this happens: click on button fires two events: onclick first then onsubmit. Because onclick sets disabled=true, all subsequent button events are immediatelly cancelled.

Another alternative is to disable button from onsubmit event (and return true).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top