473,748 Members | 3,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FireFox submitting form twice

3 New Member
I have a couple of forms that are misbehaving in FireFox, but work fine in IE.

when i do submit( with submit button) a javascript function validates all of the fields entered, and stops the submission if there is an error.

Sample (obviously not working code):
[HTML] <html>
<head>
<script type="text/javascript">
function Submit()
{
// do something, like form field validation before submitting
return true;
} else {
return false; // do nothing, do not submit the form
}
}
</script>
</head>
<body>
<form name="myForm" action="form.cg i" onSubmit="retur n Submit()>
Some form fields here<br/>
<input type="submit" value="Submit" >
</form>
</body>
</html>
[/HTML]



THE PROBLEM:
In IE, the script performs as expected.

In FireFox (tested in v2.0.0.3):
* if the form validates correctly, it gets submitted twice:
* if the form doesn't validate then nothing happen.

Am I coding something wrong here? Why is FireFox submitting the form two times..
Apr 24 '07
18 13141
Dashboard
6 New Member
What's the character encoding in your browser?
The browser encoding is - UTF-8
I've narrowed it down to my javascript stmt.
Expand|Select|Wrap|Line Numbers
  1. function mysubmit(){
  2. alert('1');
  3. document.forms[0].submit();
  4. alert('2');
  5. }
  6.  
alert('1') is displayed - No request yet submitted, Press OK, alert 2 is displayed. 2 requests submitted.
May 9 '07 #11
pbmods
5,821 Recognized Expert Expert
Change the action of your form:

[HTML]
<form ... action="mySubmi t();">
[/HTML]

And then instead of returning true in mySubmit:

Expand|Select|Wrap|Line Numbers
  1. document.forms[0].action = 'thepage.php';
  2. document.forms[0].submit();
  3.  
May 10 '07 #12
Dashboard
6 New Member
I tried to make the form action="" and set the action explicitly in the js, returned true from it. Still doesn't work.
My requirement is that the js should be called onchange of a text field, hence I've made the form action as an empty string
May 10 '07 #13
pbmods
5,821 Recognized Expert Expert
I tried to make the form action="" and set the action explicitly in the js, returned true from it. Still doesn't work.
My requirement is that the js should be called onchange of a text field, hence I've made the form action as an empty string
If the form's action is an empty string, then it will use the current page as the action. Instead, do this:

Expand|Select|Wrap|Line Numbers
  1. form.action = 'void('');';
  2.  
May 10 '07 #14
Dashboard
6 New Member
If the form's action is an empty string, then it will use the current page as the action. Instead, do this:

Expand|Select|Wrap|Line Numbers
  1. form.action = 'void('');';
  2.  

That doesn't help either
May 10 '07 #15
pbmods
5,821 Recognized Expert Expert
That doesn't help either
What's not working about it?

I'm not sure I understand how the code is fitting together; perhaps if you posted the current implementation.
May 10 '07 #16
Dashboard
6 New Member
What's not working about it?

I'm not sure I understand how the code is fitting together; perhaps if you posted the current implementation.
Here's a cut down version of my page. I've got firebug running and it issues a new get request as soon as the page is done 'rendering' the last function in the script tag below.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3.  <head>
  4.   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  5.   <meta http-equiv="Pragma" content="nocache"/>
  6.   <meta http-equiv="Cache-Control" content="private"/>
  7.   <meta http-equiv="Cache-Control" content="proxy-revalidate"/>
  8.  
  9.  
  10.  </head>
  11.  <body class="body" style="overflow:auto">
  12.   <form method="post" action="http://localhost:7001/mypage.jsp" id="S_25403" name="S_25403">
  13.    <input type="text" id="TransactionCode" title="Transaction Code" onchange="mydispatch('TransactionCode');" name="TransactionCode" value=""/>
  14.   </form>
  15.   <!-- Javascript -->
  16.   <script type="text/javascript" language="javascript1.1"><!--
  17. var pageRefreshed = true;
  18.  
  19. function mydispatch(id, cmd) {
  20.   if (pageRefreshed) {
  21.     pageRefreshed = false;
  22.     document.forms[0].submit();
  23.   }
  24.   return true;
  25. }
  26.  
  27. --></script>
  28.  </body>
  29.  
  30. </html>
  31.  

The headers for the 1st POST
Cache-Control private,proxy-revalidate, private, proxy-revalidate
Date Thu, 10 May 2007 03:00:02 GMT
Pragma No-cache, nocache
Transfer-Encoding chunked
Content-Type text/html; charset=UTF-8
Expires Thu, 01 Jan 1970 00:00:00 GMT
X-Powered-By Servlet/2.4 JSP/2.0
robots NOINDEX,NOFOLLO W
Request Headers
Host localhost:7001
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
Accept text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,ima ge/png,*/*;q=0.5
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive

And the second GET
Connection close
Date Thu, 10 May 2007 03:00:04 GMT
Content-Length 2234
Content-Type text/html
X-Powered-By Servlet/2.4 JSP/2.0
Request Headers
Host localhost:7001
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
Accept image/png,*/*;q=0.5
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
May 10 '07 #17
Dashboard
6 New Member
Solved the problem, just wanted to update the post with what he problem was-
One of my open-source js files was putting <img src="".... which was causing the page url to be accessed again.
Changed it access a null image, and it worked.

Please note that all other changes - Setting of response headers, changing the focrm action etc. were reverted back, and it still worked.

Thanx for all your help
May 10 '07 #18
acoder
16,027 Recognized Expert Moderator MVP
Solved the problem, just wanted to update the post with what he problem was-
One of my open-source js files was putting <img src="".... which was causing the page url to be accessed again.
Changed it access a null image, and it worked.

Please note that all other changes - Setting of response headers, changing the focrm action etc. were reverted back, and it still worked.

Thanx for all your help
Glad you got it working. It can be so frustrating when you realise you'd been barking up the wrong tree.
May 11 '07 #19

Sign in to post your reply or Sign up for a free account.

Similar topics

1
16034
by: fogwolf | last post by:
First a basic outline of what I am trying to do: I want to have a page spawn a pop-up when you click "submit" on its form. On this pop-up page there will be another form. When you click "submit" on the pop-up's form I want the pop-up to close & a new page to load in the "parent" window/page. I have this working in IE but cannot get it to work in Firefox. The parent window correctly loads the new page after submitting from the pop-up,...
1
1967
by: chad.arimura | last post by:
I've got a form inside a PHP script that posts to itself, does some processing on the PHP side, and if it looks good, PHP sends a HEADER command that redirects the user out. All was fine until I added a button disabler onSubmit to keep users from submitting twice. Now the form disables the button as requested but just refreshes the page... it doesn't get to the HEADER command. Any idea what the problem might be? <script...
24
3507
by: bedhead | last post by:
Why doesn't a SELECT element's innerHTML reflected which option was selected? Works in IE. I need this functionality so that I can retain what choices a user made in a tabbed interface. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://w3.org/1999/xhtml"> <head> <script language="javascript">
4
1672
by: Nacho Nachev | last post by:
This may sound like a silly question, but what is the appropriate way to handle form double submitting in ASP.NET. Page expiration, etc? I am looking for a way to handle this in some cetral point of the application without affecting the web page implementation. Thanks, Nacho
6
14463
by: Mark Olbert | last post by:
The doPostBack javascript functioning is not submitting the page when called by linkbuttons (or an autopostback checkbox, for that matter). I'm aware of a problem with Netscape browsers and the postback code, but I have a workaround for that installed (and it looks like the code generated by ASP.NET when it renders the page does the same thing, namely, setting document<). However, the problem still exists under firefox. Has anyone come...
5
4336
by: Andrea | last post by:
I am trying to alter css using javascript as well as use the innerHTML function. I have pasted below 3 forms that access getElementById in slightly different ways (I wanted to rule out that it was the method.) All 3 work fine on IE but only work momentarily on Firefox. For example, one form has text that changes from red to black when the user clicks the button. In IE it changes. In Firefox it changes for a split second then goes back...
1
2090
by: gferreri | last post by:
Hi all, I've stumbled on an interesting problem with the way Firefox handles form submitting with the enter key. I'm putting together a page that has one form element with multiple controls with their own textbox field and submit imagebuttons. I've set up each control in an asp:Panel with their DefaultButton property set to the proper button, so when the enter key is pressed, the proper button event handler is triggered. This works...
7
8358
by: mohammed.naghman | last post by:
Hi, I have 2 submit buttons in a jsp page. One of them takes me to page2.jsp and also passes the values enetered to page2.I have a link in the page2 that does a history.back to come to the previous page to make any chnages necessary. Now after making my changes, instead of going to page2.jsp if I want to submit the page, Instead of submitting the page it takes me to page2.jsp again. This problem is only with firefox. It works fine...
9
2894
by: Ned White | last post by:
Hi All, Im my c# web project, users click a submit button for credit card payment process. On the web server side ( on ButtonClick_Event) the user's input(name,date,cc number etc.) is processed and some transactional database processes are taken based on the inputs. My problem is, users may think that the button click did not work, so they can click it again and again or they can refresh the all page by pressing
0
8989
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.