473,378 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

My Javascript function doesn't work with FireFox

I have a common Jscript function in my "common.js" file
It is:

function submitForm(frm,action){
frm.action=action;
frm.submit();
return(false)
}
To submit my form fields to any other page I

Use this function like this

<A href="" onclick="return submitForm(myFormName,'\mydir\mypage.asp')">
sample link</A>

This function works completely in IE 5+ but it doesn't work in
FireFox

What is the problem?

http://www.webfreeguide.com

Jul 23 '05 #1
7 19495
Lee
Amir said:

I have a common Jscript function in my "common.js" file
It is:

function submitForm(frm,action){
frm.action=action;
frm.submit();
return(false)
}
To submit my form fields to any other page I

Use this function like this

<A href="" onclick="return submitForm(myFormName,'\mydir\mypage.asp')">
sample link</A>

This function works completely in IE 5+ but it doesn't work in
FireFox

What is the problem?


Decent browsers don't let you refer to a form simply by its name.
At the very least, you need something like:

onclick="return submitForm(document.myFormName,'\mydir\mypage.asp' )"

You should also have some reasonable value for the HREF attribute,
such as the URL of a page explaining why you don't want to allow
people with Javascript disabled to be able to submit your form.

Jul 23 '05 #2
try using <a href="#" ...

micha

Jul 23 '05 #3
"Amir" <we*******@webfreeguide.com> wrote:
I have a common Jscript function in my "common.js" file
It is:

function submitForm(frm,action){
frm.action=action;
frm.submit();
return(false)
}
To submit my form fields to any other page I

Use this function like this

<A href="" onclick="return submitForm(myFormName,'\mydir\mypage.asp')">
sample link</A>

This function works completely in IE 5+ but it doesn't work in
FireFox

What is the problem?


Instead of

frm.action=action;

try:

document.getElementById(frm).action=action;

where "frm" is the ID attribute of your form.

--
Tim Slattery
Sl********@bls.gov
Jul 23 '05 #4

"Tim Slattery" <Sl********@bls.gov> wrote in message
news:5v********************************@4ax.com...
"Amir" <we*******@webfreeguide.com> wrote:
I have a common Jscript function in my "common.js" file
It is:

function submitForm(frm,action){
frm.action=action;
frm.submit();
return(false)
}
To submit my form fields to any other page I

Use this function like this

<A href="" onclick="return submitForm(myFormName,'\mydir\mypage.asp')">
sample link</A>

This function works completely in IE 5+ but it doesn't work in
FireFox

What is the problem?
Instead of

frm.action=action;

try:

document.getElementById(frm).action=action;

where "frm" is the ID attribute of your form.


using the name attribute or index into the forms array seems to me the
safest way to reference the form.
IIRC the name att is a must in compliant browsers and is supported in all
UA's.
document.forms[0].etc
document.forms['idAtt'].etc

Jimbo

--
Tim Slattery
Sl********@bls.gov

Jul 23 '05 #5
J. J. Cale wrote:

[snip]
using the name attribute or index into the forms array seems to me
the safest way to reference the form.
The forms collection. The object isn't actually an array (in an
ECMAScript sense).
IIRC the name att is a must in compliant browsers and is supported
in all UA's.


Only in that it is the most used method. The preferred approach is to
use the id attribute; the name attribute has been relegated to a state
of backwards compatibility. In theory, this means a future version of
HTML can deprecate the name attribute. In fact, this has happened in
XHTML 1.0 - the name attribute isn't defined in the Strict DTD.

FORM elements should be "labeled" using the id attribute. If
compatibility with ancient browsers like NN4 is desired, add the name
attribute as well. This also applies to images.

Whatever approach you take, it is still preferable to use the forms
(or images) collections as these are well supported and will accept
both name and id attribute values.

Mike
Be aware that this discussion does not extend to form controls (INPUT,
etc).

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #6
J. J. Cale wrote:
[...]
using the name attribute or index into the forms array seems to me the
safest way to reference the form.
IIRC the name att is a must in compliant browsers and is supported in all
UA's.


Hmmm. In regard to the name attribute of forms, the w3c HTML
4.01 spec says:

"name = cdata [CI]
This attribute names the element so that it may be referred to
from style sheets or scripts. Note. This attribute has been
included for backwards compatibility. Applications should use
the id attribute to identify elements."

<URL:http://www.w3.org/TR/html4/interact/forms.html#adef-name-FORM>

So whilst the name attribute of a form continues to be supported
(and I think your opinion regarding its use is correct), working
solely from the spec may result in a different point of view.

--
Rob
Jul 23 '05 #7

"Michael Winter" <m.******@blueyonder.co.invalid> wrote in message
news:Fz*****************@text.news.blueyonder.co.u k...
J. J. Cale wrote:

[snip]
using the name attribute or index into the forms array seems to me
the safest way to reference the form.
The forms collection. The object isn't actually an array (in an
ECMAScript sense).
IIRC the name att is a must in compliant browsers and is supported
in all UA's.


Only in that it is the most used method. The preferred approach is to
use the id attribute; the name attribute has been relegated to a state
of backwards compatibility. In theory, this means a future version of
HTML can deprecate the name attribute. In fact, this has happened in
XHTML 1.0 - the name attribute isn't defined in the Strict DTD.

FORM elements should be "labeled" using the id attribute. If
compatibility with ancient browsers like NN4 is desired, add the name
attribute as well. This also applies to images.

Whatever approach you take, it is still preferable to use the forms
(or images) collections as these are well supported and will accept
both name and id attribute values.

Mike
Be aware that this discussion does not extend to form controls (INPUT,
etc).


Thanks guys. I'm over my head here. Is the name attribute necessary in a
control?
I don't keep an efficient archive but I recall a situation where I tried to
reference
an input in a form and came up empty. I don't remember the error msg but it
was
resolved by adding the name attribute which conclusion I got from one of the
specs.
Again I'm sorry for my poor archiving. I really tried to find the example
but it's buried
somewhere on my hard disk. Hope I haven't added to the confusion. Thanks for
correcting me.
Jimbo
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.

Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Joe | last post by:
I'm trying to create an image preview function so that my users can preview images before they upload them. I've got my example working locally on both Firefox and IE, and from the webserver in IE....
3
by: milkyway | last post by:
Hello, I am working with an old Java Script code and have found the following but after putting in alerts I have found that insertRow doesn't work. What is the problem? TIA function...
14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
8
by: bradwiseathome | last post by:
I have code that works in IE 6 but does not work in FireFox 1.0.2, how can I change it so it works in both browsers? <html> <head> <script language="JavaScript" type="text/JavaScript">...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
16
by: Phlip | last post by:
Javascripters: I have a page with an iframe inside. Let's say the iframe looks like this: <script src="/javascripts/prototype.js" type="text/javascript" /> .... <iframe id='grinder'...
15
by: Phlip | last post by:
Javascripters: I have an outer page and an inner iframe. The outer page calculates some javascript, and wants the inner frame to run it. The inner frame should hit a page on the same (private)...
1
by: Bombtrack | last post by:
I have some javascript code that errors in FireFox, but only when I use a DOCTYPE expression at the top of the page - until I added that, it worked fine in both IE and FireFox. Here is the...
2
by: Matthew Wells | last post by:
Hello. I'm reposting this because my prioe post's subject line was incorrect. I'm developing an asp.net 2.0 project using VS 2005 on XP sp2 with all the updates. I have an aspx page with...
8
by: Mateusz Viste | last post by:
Hi, I'm not sure if my question is really related to JavaScript, so please excuse me if that's not the case (and maybe you guys would have an idea what's the cause is and where could I ask)... ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.