firefox problem with accessing form value

J

judy.j.miller

Does anyone know why i can't access a form element value using dot
notation in firefox, when i'm in a function. Works ok in the body.
I'm trying to do this:

var FarTemp = faren.temp.value;

I can get at the value using the array method, the getelements by id
method, and the bracket-with-the-element-name in it method. But the
dot notation doesn't work, in firefox, in the function (which i have
in the head).

Thanks for any help.
 
L

Lee

(e-mail address removed) said:
Does anyone know why i can't access a form element value using dot
notation in firefox, when i'm in a function. Works ok in the body.
I'm trying to do this:

var FarTemp = faren.temp.value;

I can get at the value using the array method, the getelements by id
method, and the bracket-with-the-element-name in it method. But the
dot notation doesn't work, in firefox, in the function (which i have
in the head).

That's not a valid reference to a form value, although some sloppy
browsers allow it:

var FarTemp = document.faren.temp.value;

is probably what you're looking for.


--
 
J

judy.j.miller

Mr. Talbot, Thank you very much.


(e-mail address removed) wrote :
Does anyone know why i can't access a form element value using dot
notation in firefox, when i'm in a function. Works ok in the body.
I'm trying to do this:
var FarTemp = faren.temp.value;

This is a typical error in accessing form values. Please visit

Using Web Standards in your Web Pages
Section 3.2: Accessing Elements with the W3C DOMhttp://developer.mozilla.org/en/docs/Using_Web_Standards_in_your_Web_...

Also:

Referencing Forms and Form Controls by comp.lang.javascript newsgroup
FAQ notes
<http://jibbering.com/faq/faq_notes/form_access.html>

DOM 2 specification on accessing forms and form elements
<http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-40002357>

Javascript Best Practices: Referencing Forms and Form elements
correctly, by Matt Kruse
<http://www.javascripttoolbox.com/bestpractices/#forms>

Making your web page compatible with Mozilla from Nicolás Lichtmaier
I can get at the value using the array method, the getelements by id
method, and the bracket-with-the-element-name in it method. But the
dot notation doesn't work, in firefox, in the function (which i have
in the head).
Thanks for any help.

var FarTemp = document.forms["faren"].temp.value;
or
var FarTemp = document.forms["faren"].elements["temp"].value;

FormName.InputName.value
can be replaced with
document.forms["FormName"].InputName.value
or
document.forms["FormName"].elements["InputName"].value

Gérard
 

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

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top