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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using function to disable submit button, but does not submit changes

Status
Not open for further replies.

tokuzumi

Programmer
Sep 16, 2002
40
US
I use the following function to disable the submit button, so a user cannot click it twice:

function disable()
{
document.form1.submit.disabled = true;
document.form1.submit.value = "Edit Project";
}

And I call it this way:

<form method=&quot;post&quot; name=&quot;form1&quot; id=&quot;form1&quot; onSubmit=&quot;javascript:disable()&quot;>

The function works, but if any changes are made to the fields on the form, the changes are not submitted to the database. When I run the page in Debug, I notice the value of the submit button is &quot;Empty&quot;. &quot;Edit Project&quot; is what I titled the submit button on my form. The function used to say &quot;Submit&quot;, instead of &quot;Edit Project&quot;. Why is this making the value of the submit button empty? Thanks.
 

post the code and the answer will follow...

- g
 
When the user submits the form, the value of the submit button is equal to empty. So, any changes the user wants to submit, after filling out the form, are not saved.

All of the code for the javascript is in my post.

I'm not sure what you mean by &quot;post the code...&quot;
 
when you disable a form field, the effect is the same as if the element is not in the form.

perhaps try something like:

function submitOnce() {
if (window.submitted) return false;
else {
// form validation, etc...
}
window.submitted = true;
}


<form onsubmit=&quot;return submitOnce();&quot;>
=========================================================
while (!succeed) try();
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top