[Javascript] disabling form on submit
Shawn Milo
milo at linuxmail.org
Tue May 25 07:05:28 CDT 2004
In one of my earlier posts, I professed a belief that any HTML
objects changed after the submit button was pressed wouldn't make
a difference, anyway. I suggested something to the effect of:
onsubmit (or in the onclick of the button, if you prefer)
if the submit button's value == 'Please Wait', return false
else, the submit button's value = 'Please Wait'.
I have tested my theory, and it appears that changes made
after the submit are indeed lost.
Test page:
<html>
<head>
<title>
Proof of concept
</title>
<script type="text/javascript">
function submitPage(){
document.forms['testForm'].submit();
document.forms['testForm'].field01.value = 'unwanted';
document.forms['testForm'].field02.value = 'bad data';
}
</script>
</head>
<body>
<form id="testForm" method="get" action="./test2.html">
<input type="text" id="field01" name="field01" value="" /><br/>
<input type="text" id="field02" name="field02" value="" /><br/>
<input type="button" value="Submit" name="btnSubmit" id="btnSubmit" onclick="submitPage();" />
</form>
</body>
</html>
Shawn
----- Original Message -----
From: "Hugo Ahlenius" <Hugo.Ahlenius at grida.no>
Date: Tue, 25 May 2004 10:21:19 +0200
To: "[JavaScript List]" <javascript at LaTech.edu>
Subject: RE: [Javascript] disabling form on submit
| Anyway, did the original poster ever get their page working
| as desired? If so, which (if any) of the suggestions from
| the group did the trick?
The Original Poster speaking: I haven't tried any of the suggestions,
since they don't offer me more than I have -- currently I have an
include that disables all form elements after submit, but I need to add
code for the "onsubmit" event of the form tag (my goals is to avoid
that).
But the discussion gave me an idea: one could, on the submit event a)
create a bunch of hidden form elements duplicating the existing ones,
and b) then disable the non-hidden form elements.
###########################################
This message has been scanned by F-Secure Anti-Virus for Microsoft
Exchange.
For more information, connect to http://www.F-Secure.com/
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list