Robert Mark Bram wrote:
Howdy All!
Is there any difference between referencing objects and attributes with dot
notation or bracket notation?
Example,
document.formname.controlname
document [formname] [controlname]
Can I access attributes and objects equally with both?
Thanks for any advice!
Member access is defined with the bracket notation but note that inside
the brackets you need an expression which is then evaluated and
converted to a string. Thus above for
document.formname
you need
document["formname"]
as the equivalent bracket notation.
The bracket notation is more flexible as you can put any expression like
a variable in there, the dot notation is shorter but you need to know
member names at coding time and you can only use valid identifiers while
the bracket notation allows arbritrary names e.g.
document["form-name"]
--
Martin Honnen
http://JavaScript.FAQTs.com/