On 6 Nov 98, Jack Killpatrick wrote:
> with a dot (.) after form, but I tried that and it didn't work. I guess
> javascript replaces the first [ with a dot? If so, why doesn't it replace
> the 2nd one? I tried:
>
> form["thing_"+number+"_deluxe"]value = "joey";
>
> with no dot after the ], but it generates an error. Hmm.
Each successive dot means you're going farther down into the DOM: if you
were referencing, say 'window.document.form6.text3.value', you'd be
starting at the top of the DOM (the window); then moving to the
document open in that window; down to a form named 'form6'; to a text
field named 'text3'; and finally to the value of 'text3'. This is comparable
to how C and Java maintain hierarchical relationships.
The sqaure brackets, on the other hand, normally specify arrayed (and
similar) objects within a given level of the DOM; so that in your example,
the brackets denote 'window.document.[thing_1_deluxe].value',
'window.document.[thing_2_deluxe].value', etc, all of which are
associated with the same form. That is, they occupy different locations in
the same index that Javascript creates for that particular form.
If the names of the form and its subsidiary elements are not correctly
separated by dots showing their place in the DOM hierarchy, then you'll
certainly get errors.
- Brent "been staying up late reading JS manuals the past few
weeks" Eades
-----------
Brent Eades, Almonte, Ontario
E-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
Town of Almonte site: http://www.almonte.com/
Business site: http://www.federalweb.com
____________________________________________________________________
--------------------------------------------------------------------
Join The Web Consultants Association : Register on our web site Now
Web Consultants Web Site : http://just4u.com/webconsultants
If you lose the instructions All subscription/unsubscribing can be done
directly from our website for all our lists.
---------------------------------------------------------------------