• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

FREEZE/DISABLE SUBMIT BUTTON WHILST PROCESSING

Hi

Im looking to disable a submit button while a transaction is processing.
ie sometimes the page has to call 3rd party vendors and can take 30 seconds and I need to be able to ensure the submit button is not pressed again

Javascript or asp..

thanks
0
louise_8
Asked:
louise_8
  • 5
  • 3
  • 2
1 Solution
 
GaryCommented:
In the onclick of the button

onclick='document.getElementById("buttonid").disabled = true;this.submit()'

Though if you are doing other processing then this will obviously go in your js routine.
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
to simplify Gary's suggestion (which is mostly correct), you could also do the following on the onclick of the button:

onclick='this.disabled = true'; document.frmName.submit()'

I also changed the second line of JS to reference the form name; since its attached to the onclick of a button, reference "this" is referencing the button and not the form
0
 
louise_8Author Commented:
Hi

This works fine for ie9, firefox and Chrome
however ie8 the page doesnt submit

any ideas why?
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
can you post the exact code you're using? also, are there any JS errors appearing?
0
 
louise_8Author Commented:
Hi
Sorry for the delay, I'd to get my testers response..

There are no js errors

Its ok ie FF, chrome and ie9 but in ie8 it disables the button and doesnt submit the page.

I've pasted the relevant code below.  It shows the alert in SubmitOrder() but doesnt post the page in ie8

*CODE*

<form name="frmWholesalerPurchase" method="post" onsubmit="return fValidate();" ID="Form1">
<INPUT type="submit" value="Submit Order" ID="Submit3" NAME="bSubmit" onclick="this.disabled = true;SubmitOrder()">

function SubmitOrder()
{
      if (frmWholesalerPurchase.mTotal == null)
      {
            alert("No  <%=vClientType%> applied!")
            return false;
      }
      
      
      frmWholesalerPurchase.action = "WholesalerPurchaseHO2.asp";
      alert("Order is being submitted!" );
      


}

function fValidate()
{

            
      if (window.opener.document.frmCustomer.vCompany.value == ""  )
      {
            alert("This customer has an invalid Pharmacy name, please enter a pharmacy name into the company/ pharmacy field before proceeding!");
            return false
      }
      
}
0
 
louise_8Author Commented:
I have just run another test, ie ie8 after it displays the alert   alert("Order is being submitted!" );
it does not run the fValidate function

So ie8 is no longer running the onsubmit="return fValidate();" code..
0
 
GaryCommented:
Call the validate function in your submitorder function not in the forms onsubmit
0
 
louise_8Author Commented:
It needs to be called for submit buttons so I'd prefer not to do that..

if I called it in the submitorder function too, it would mess up the browsers that work (I assume)
0
 
GaryCommented:
Uhh
After passing validation for  if (frmWholesalerPurchase.mTotal == null)
Call the validate - it's the same logic as you have now just wrapped up in the js.
0
 
louise_8Author Commented:
thanks
I went with this as a workaround rather than a fix to the ie8 specific issue

Appreciate your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now