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!

disable and submit in one onClick statement.

Status
Not open for further replies.

Jayson

Programmer
Jan 31, 2001
75
0
0
US
I have a form which is submitted using an <input> tag,
within that i have:
<input type=&quot;submit&quot; value=&quot;Create&quot; name=&quot;Create&quot; onClick='this.form.Create.disabled=true;this.form.Submit();'>

what i'm trying to do is first disable the button, so users cannot keep on pressing the button, after which, it submits the form... the reason why i need this is bec, when the submit button is click, the query behind it takes time to execute, so impatient users can click on it multiple times, which will result to multiple entries.
 
Try this :

Code:
<script>
<!--
  function formcheck() {
      document.my_form.disabled=true;
      document.my_form.submit()
      return false;
  }
//-->
</script>

<form name=&quot;my_form&quot; action=&quot;page.cgi&quot; method=&quot;post&quot; onsubmit=&quot;return formcheck()&quot;>
  <input type=&quot;text&quot; name=&quot;foo&quot;>
  <input type=&quot;text&quot; name=&quot;bar&quot;>
  <input type=&quot;submit&quot; name=&quot;subut&quot; value=&quot;Create&quot;>
</form>
Regards

Big Dave

davidbyng@hotmail.com


** If I am wrong I am sorry, but i'm only trying to help!! **

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top