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.cgi" onSubmit="return 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..
18 13064
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>
<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.cgi" onSubmit="return Submit()>
Some form fields here<br/>
<input type="submit" value="Submit" >
</form>
</body>
</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..
I'm not a FireFox guru and am just trying my luck here,
What happens if you call the function onClick of the submit button rather than onSubmit of the form?
try to change the function name
try to change the function name
Of course. That should be it.
i tried to use onclick and the results are same.
btw, onclick event will take care of only mouse click.
but i need to make it generic,
I want to use all three cases.
a) submitting page by enter.
b) submitting page by click
c) submitting page by space when control is on submit button,
i have tried with changing function but no luck.
is there any other way, i can look on.
Thanks
i tried to use onclick and the results are same.
btw, onclick event will take care of only mouse click.
but i need to make it generic,
I want to use all three cases.
a) submitting page by enter.
b) submitting page by click
c) submitting page by space when control is on submit button,
i have tried with changing function but no luck.
is there any other way, i can look on.
Thanks
Can you post the code you have now with the function name changed
Firefox automaticqally follows the submit standard function after an event has occured when using a submit button...if you change the button type to button instead of submit and change the function name it will work normally. Unfortunatley you loose some of the other funtionality options you want but give a little to get a little. Sorry
Firefox automaticqally follows the submit standard function after an event has occured when using a submit button...if you change the button type to button instead of submit and change the function name it will work normally. Unfortunatley you loose some of the other funtionality options you want but give a little to get a little. Sorry
i found the solution afterall :)
the page was being loaded with GET method and issue was -- " mismatching of character encoding" ( hence GET was being executed Twice )
i used Central European ISO-8859-2 and everything is working fine
refer the below link for more details .. http://forums.mozillazine.org/viewto...859258#2859258
Regards
Navin
I'm still getting the problem. I've checked and set the charset encoding on the response header but with no luck [UTF-8]. FF still issues a Post and then a Get. Could someone please detail out how the solution is working for them.
One thing to note is that I use javascript to submit my form onchange of a text field. That should not make a difference.
The page meta tags -
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Pragma" content="nocache"/>
<meta http-equiv="Cache-Control" content="private"/>
<meta http-equiv="Cache-Control" content="proxy-revalidate"/>
Note I tried with the following as well -
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Pragma" content="no-cache,no-store,max-age=0"/>
<meta http-equiv="Cache-Control" content="nocache"/>
In my servlet I set the following
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache,no-store,max-age=0");
response.setHeader("Content-Type", "text/html; charset=UTF-8");
response.setDateHeader("Expires", 1);
Am I doing something wrong here?
I'm still getting the problem. I've checked and set the charset encoding on the response header but with no luck [UTF-8]. FF still issues a Post and then a Get. Could someone please detail out how the solution is working for them.
One thing to note is that I use javascript to submit my form onchange of a text field. That should not make a difference.
The page meta tags -
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Pragma" content="nocache"/>
<meta http-equiv="Cache-Control" content="private"/>
<meta http-equiv="Cache-Control" content="proxy-revalidate"/>
Note I tried with the following as well -
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Pragma" content="no-cache,no-store,max-age=0"/>
<meta http-equiv="Cache-Control" content="nocache"/>
In my servlet I set the following
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache,no-store,max-age=0");
response.setHeader("Content-Type", "text/html; charset=UTF-8");
response.setDateHeader("Expires", 1);
Am I doing something wrong here?
What's the character encoding in your browser?
What's the character encoding in your browser?
The browser encoding is - UTF-8
I've narrowed it down to my javascript stmt. -
function mysubmit(){
-
alert('1');
-
document.forms[0].submit();
-
alert('2');
-
}
-
alert('1') is displayed - No request yet submitted, Press OK, alert 2 is displayed. 2 requests submitted.
Change the action of your form:
[HTML]
<form ... action="mySubmit();">
[/HTML]
And then instead of returning true in mySubmit: -
document.forms[0].action = 'thepage.php';
-
document.forms[0].submit();
-
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
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: -
form.action = 'void('');';
-
If the form's action is an empty string, then it will use the current page as the action. Instead, do this: -
form.action = 'void('');';
-
That doesn't help either
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.
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. -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
<html>
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-
<meta http-equiv="Pragma" content="nocache"/>
-
<meta http-equiv="Cache-Control" content="private"/>
-
<meta http-equiv="Cache-Control" content="proxy-revalidate"/>
-
-
-
</head>
-
<body class="body" style="overflow:auto">
-
<form method="post" action="http://localhost:7001/mypage.jsp" id="S_25403" name="S_25403">
-
<input type="text" id="TransactionCode" title="Transaction Code" onchange="mydispatch('TransactionCode');" name="TransactionCode" value=""/>
-
</form>
-
<!-- Javascript -->
-
<script type="text/javascript" language="javascript1.1"><!--
-
var pageRefreshed = true;
-
-
function mydispatch(id, cmd) {
-
if (pageRefreshed) {
-
pageRefreshed = false;
-
document.forms[0].submit();
-
}
-
return true;
-
}
-
-
--></script>
-
</body>
-
-
</html>
-
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,NOFOLLOW
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,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
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
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
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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"...
|
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...
|
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.
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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,...
|
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...
| |