Forum Moderators: open
Here is the javascript function:
function disableButton(theButton)
{
theButton.value="Processing...";
theButton.disabled = true;
document.forms[0].submit();
}
And here is the form that calls the function:
<form onSubmit="disableButton(document.form1.submit2);" method="post" action="" style="margin:0" name="form1" id="form1">
<OTHER STUFF REMOVED FOR BREVITY>
<input type="submit" name="submit2" value="SUBMIT ORDER">
</form> ----------
Like I said, I have tested this in Mozilla, Opera, IE, etc, and haven't had any problems or even javascript warnings. Any ideas?
function disableButton(theButton)
{
theButton.value="Processing...";
theButton.disabled = true;
return true;
}
And here is the form that calls the function:
<FORM onSubmit="return disableButton(this.submit2);" method="post" action="">
...
<INPUT type="submit" name="submit2" value="SUBMIT ORDER">
</FORM>
Works fine in Safari at least ;)
The problem with Safari's JS is mostly that it doesn't include a debugger or events window.
I went to the Apple site, but couldn't find much info regarding Safari bugs and limitations. They don't appear to be particularly forthcoming, for an open-source project. If you have access to a Linux box, you might try using Konquerer to test, as Safari is based on it.
Another approach might be to allow the standard submit action of the form to execute, after a function called by onsubmit determines that it is the first submission and returns "true"; conversely if the function finds that a submission has already been made, it could return "false". This would actually be a more "standard" approach.
function disableButton(theButton)
{
theButton.value="Processing...";
theButton.disabled = true;
return true;
}
<FORM onSubmit="return disableButton(this.submit2);" method="post" action="">
...
<INPUT type="submit" name="submit2" value="SUBMIT ORDER">
</FORM>
I tested this on Konqueror for Linux and it worked fine. I would still like to test it on a real mac with Safari. Is there anyone out there willing to test for me? If so, please sticky me and I'll send you the URL.
Thanks!