473,382 Members | 1,425 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,382 software developers and data experts.

getElementByID problems in Firefox

Bob
This works fine in IE6.

monDoc = document.getElementById('tbMonth');
mon = monDoc.value;

But Firefox doesn't recognize the value property. What works in FF?

Oct 21 '06 #1
3 4924
Bob said the following on 10/21/2006 3:08 PM:
This works fine in IE6.
Probably because IE doesn't know the difference between a NAME attribute
and an ID attribute.
monDoc = document.getElementById('tbMonth');
mon = monDoc.value;

But Firefox doesn't recognize the value property. What works in FF?
Without seeing your HTML, that is impossible to answer.

You probably have an input with a name attribute of "tbMonth". If so,
use the form collection to access it:

document.forms['formIDnotName'].elements['elementNAMEnotID'].value;

Or, change your attribute from name to ID, or use both.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Oct 21 '06 #2
Bob

Randy Webb wrote:
Bob said the following on 10/21/2006 3:08 PM:
This works fine in IE6.

Probably because IE doesn't know the difference between a NAME attribute
and an ID attribute.
monDoc = document.getElementById('tbMonth');
mon = monDoc.value;

But Firefox doesn't recognize the value property. What works in FF?

Without seeing your HTML, that is impossible to answer.

You probably have an input with a name attribute of "tbMonth". If so,
use the form collection to access it:

document.forms['formIDnotName'].elements['elementNAMEnotID'].value;

Or, change your attribute from name to ID, or use both.
Thanks Randy, I added the id attribute so it has both name and id, and
all works fine.

Oct 21 '06 #3
Bob

Randy Webb wrote:
Bob said the following on 10/21/2006 3:08 PM:
This works fine in IE6.

Probably because IE doesn't know the difference between a NAME attribute
and an ID attribute.
monDoc = document.getElementById('tbMonth');
mon = monDoc.value;

But Firefox doesn't recognize the value property. What works in FF?

Without seeing your HTML, that is impossible to answer.

You probably have an input with a name attribute of "tbMonth". If so,
use the form collection to access it:

document.forms['formIDnotName'].elements['elementNAMEnotID'].value;

Or, change your attribute from name to ID, or use both.
Thanks Randy, I added the id attribute so it has both name and id, and
all works fine.

Oct 21 '06 #4

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

Similar topics

3
by: davidkarlsson74 | last post by:
Error: document.getElementById("folderMenu").cells has no properties File: http://www.volkswagen.se/tillbehor/js/foldermenu.js Rad: 49 The function activates different DIV:s, but doesn't seem to...
5
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...
4
by: the other john | last post by:
I came across a third party script I want to learn how to configure as well as learn more dhtml in the doing. I'm not much of a JS guy yet but I'm working on it. This script works fine in IE6...
5
by: antonyliu2002 | last post by:
Hi, It looks like so many people are having problems with the javascript submit in firefox. I searched around, but haven't found a solution yet. Mostly, people were saying, try this or try...
13
by: RommelTJ | last post by:
Hi, My website (http://www.justiceinmexico.org/indextest.php) looks good in Firefox, but horrible in IE, and I think it's because of an error in the javascript of a free web ticker I got off the...
29
by: Nick | last post by:
I've seen a few frameworks use the following: function $(id) { return document.getElementById(id); } Then to use: $('something').innerHTML = 'blah'; I'm just trying to roll this out to my...
8
by: cyqotiq | last post by:
First, let me state that this is not necessarily a Firefox problem, as I haven't fully tested in IE just yet. Second, let me state that this is not the typical "getElementById not working Firefox"...
3
by: GarryJones | last post by:
The following works in MSIE but not firefox. I suspect it has something to do with the fact that the element I am trying to access is not the "tid" which is the name of the DIV that is passed to...
1
by: vikD | last post by:
Hello, I'm really bad at javascript but I managed to get the code below to work in IE but firefox gives this error... Error: document.getElementById.formall is undefined Basically use the...
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.