getElementByID problems in Firefox

B

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?
 
R

Randy Webb

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.
 
B

Bob

Randy said:
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.
 
B

Bob

Randy said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top