473,883 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=acti on;
frm.submit();
return(false)
}
To submit my form fields to any other page I

Use this function like this

<A href="" onclick="return submitForm(myFo rmName,'\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 19535
Lee
Amir said:

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

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

Use this function like this

<A href="" onclick="return submitForm(myFo rmName,'\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(docu ment.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*******@webf reeguide.com> wrote:
I have a common Jscript function in my "common.js" file
It is:

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

Use this function like this

<A href="" onclick="return submitForm(myFo rmName,'\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=acti on;

try:

document.getEle mentById(frm).a ction=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.c om...
"Amir" <we*******@webf reeguide.com> wrote:
I have a common Jscript function in my "common.js" file
It is:

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

Use this function like this

<A href="" onclick="return submitForm(myFo rmName,'\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=acti on;

try:

document.getEle mentById(frm).a ction=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.******@bluey onder.co.invali d> wrote in message
news:Fz******** *********@text. news.blueyonder .co.uk...
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
1845
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. However, when I try to access the example via a webserver and Firefox, it doesn't work. Any help with this would be greatly appreciated. (Code listed below:) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
3
16208
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 addRowDOM (tableID) {
14
5507
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 that works well as an html page. It brings up a modal popup window that I have been trying to work out for days now and this was the closest I have been able to come. I added a little asp.net code and an asp.net button and cannot get it to
8
1835
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"> function AttributeSelected() { var selectVal = document.forms.elements.options;
8
3685
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
16
1857
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' src='sample.html' > </iframe> That prototype.js gives us goodies like $(). And sample.html looks a little
15
2285
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) web server, so this is not a cross-site scripting attack. But I would prefer not to taint the target page with any extra logic to do this. (I will if I must.) The calling page has these elements:
1
2147
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 declaration at the top of my page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> This function errors claiming that divBtContinue does not exist (and if I comment out that line I'm told divBtSubmit...
2
2752
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 javascript that works fine until I try to separate the script into a .js file. I've found that only the script that is called from events set in the aspx.cs file don't work. I eliminated all script except two functions. One is used with the .cs file...
8
5221
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)... I recently put the following script online: <script type="text/javascript"><!-- function playmedia(mediafile) { newwindow=window.open(); if (window.focus) {newwindow.focus()} newwindow.document.write('<html>');
0
9940
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
11141
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10415
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
7126
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();...
0
5797
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5991
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4611
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
2
4220
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3232
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.