Undefined form error in Firefox

I have this code, say a.html

 <form name="frmSubmit" id="frmSubmit" method="post"> <input type="hidden" name="hdnName" value="user name" /> </form> <script> // 1 : start document.frmSubmit.action = 'b.html'; document.frmSubmit.submit(); // 1 : end // 2 : start document.getElementById("frmSubmit").action = 'b.html'; document.getElementById("frmSubmit").submit(); // 2 : end </script> 

Both users 1 and 2 work in IE (IE 8), but not in FF (3.6.10). Firebug gives me the following error:

document.frmSubmit undefined

How can i fix this?

+6
javascript forms
source share
4 answers
 <html> <head> <script> function setup(){ // 1 : start document.frmSubmit.action = 'b.html'; document.frmSubmit.submit(); // 1 : end // 2 : start document.getElementById("frmSubmit").action = 'b.html'; document.getElementById("frmSubmit").submit(); // 2 : end } </script> </head> <body onload="setup()"> <form name="frmSubmit" id="frmSubmit" method="post"> <input type="hidden" name="hdnName" value="user name" /> </form> </body> </html> 
+1
source share

Usually, when I am going to encode these workarrounds to avoid errors, to stop execution, I surround conflicting blocks with try & cathc. I would recommend surrounding 1 and 2 with try / catch blocks, so there is an error there, it does not stop the execution of the script.

0
source share

I had the same problem and managed to get it to work by doing the following:

  • You have an image button or any other postback object in your form that displays what you want ("buy now!").
  • In the case when it was clicked, enter the event in codebehind.
  • When the event is clicked, make response.redirect to the new page that you will create (postpaypal.aspx).
  • Create a new file (postpaypal.aspx) that does not use the main page, has its own form and standard PayPal code and actions.

It worked great for me and was simple and efficient.

0
source share

Please check if you have provided input type = "submit" name = "submit" value = "Continue"

Instead, the name should be input type = "submit" name = "sub" value = "Continue"

NB: the name must be other than "send"

0
source share

All Articles