[Javascript] disabling form on submit
Shawn Milo
milo at linuxmail.org
Mon May 24 12:37:32 CDT 2004
I believe that any changes made to form elements after the form
has been submitted are meaningless. On submit, the existing
values are sent.
Disabling the submit button 'onsubmit' causes a problem if the
page which accepts the submitted form relies on the value of
the submit button to decide which action to take, because
disabling the button on submit causes the button to return
no value.
For example, if my ASP page has something like one of the
following, the code will never execute.
If Request.Form("btnSubmit") <> "" Then
'do some stuff
End If
Or:
Select Case Request.Form("btnSubmit")
Case "add"
'do the add stuff
Case "edit"
'do the add stuff
Case "delete"
'do the add stuff
End Select
Shawn
----- Original Message -----
From: Paul Novitski <paul at novitskisoftware.com>
Date: Mon, 24 May 2004 10:24:55 -0700
To: "[JavaScript List]" <javascript at LaTech.edu>
Subject: Re: [Javascript] disabling form on submit
> At 09:52 AM 5/24/2004, Hugo Ahlenius wrote:
> >My idea is to have an include that disables all the form elements on
> >submit of the form (to signal that it is processing, and to prevent the
> >user from pressing the submit button multiple times).
> >
> >My problem is that if the form elements are disabled before the
> >submit, then they are not sent to the action Url (expected behaviour).
>
>
> Hugo,
>
> I've always had good success disabling the submit button alone. I suppose
> it *might* be possible to change the value of input fields after clicking
> submit and have the changed values communicate to the server (if the typist
> is very quick or the browser is very slow), but I've never had a problem
> with that.
>
> Below is my quickie suggestion (sorry no time to test it).
>
> Paul
> _______________________________
>
> // set up the event when the page has loaded
> window.onload = jsSubmitOnceInit
>
> // set up the submit button
> function jsSubmitOnceInit()
> {
> var oSubmit = document.getElementById("SubmitOnce")
> oSubmit.onclick = jsSubmitOnce
> }
>
> // when button is clicked, disable it before submitting form
> function jsSubmitOnce()
> {
> this.enabled = false
> this.form.submit()
> }
> ...
> <input type="submit" id="SubmitOnce">
>
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list