[Javascript] disabling form on submit

Shawn Milo milo at linuxmail.org
Mon May 24 15:16:22 CDT 2004


I guess it depends upon what you're doing, because in
ASP the value of the button (the caption) *is* returned.

A button which not selected is not returned in the
Request.Form array, that is true.

In the script below, I do not see how it can work,
because the element is not passed to the function.
How does the function know which button to alter?

Granted, I did not test it, because I'm going home in
a few minutes, and am therefore extremely lazy.

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?

Shawn





----- Original Message -----
From: Paul Novitski <paul at novitskisoftware.com>
Date: Mon, 24 May 2004 11:38:53 -0700
To: "[JavaScript List]" <javascript at LaTech.edu>
Subject: Re: [Javascript] disabling form on submit

> Shawn Milo wrote:
> >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.
> 
> And then he wrote:
> >Onsubmit, if the value of the submit
> >button == 'Please Wait', return false.
> >
> >Onsubmit, change the value of the
> >submit button to "Please Wait".
> 
> 
> Ah, you've stirred the sediment enough for some old logic to burble up 
> through the murk.
> 
> Here are two submit buttons, both calling the same submit routine:
> 
> <input
>   type="submit"
>   name="verbEdit"
>   value="Edit Item"
>   onclick="jsSubmit()"
>  >
> 
> <input
>   type="submit"
>   name="verbDelete"
>   value="Delete Item"
>   onclick="jsSubmit()"
>  >
> 
> ...
> 
> var bSubmitted = false
> var sSendingPrompt = "Please wait..."
> 
> function jsSubmit()
> {
>          // allow submit to happen only once
>                  if (bSubmitted) return false
>          bSubmitted = true
> 
>          // change the button face to "wait" prompt
>          this.value = sSendingPrompt
> 
>          // allow the form to submit
>          return true
> }
> 
> On click, the clicked button changes to a Wait prompt.
> 
> Only one form submission is permitted to occur.
> 
> Per HTML, when the markup contains multiple submit buttons only the one 
> that's clicked shows up in the form element array.
> 
> Because the button face text *is* the value of the submit button, the 
> server-side script looks for a form element named "verbEdit" or 
> "verbDelete" and ignores its value.
> 
> As I recall, I couldn't change the button face text with the direct statement:
>          this.value = "Please wait..."
> but instead had to use a variable for some mysterious reason...
> 
> Paul 
> 
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list