On Mon, 9 Feb 2004 17:46:40 -0000, Richard Cornford
<Richard@litotes.demon.co.uk> wrote:
[color=blue]
> "Michael Winter" <M.Winter@blueyonder.co.invalid> wrote in message
> news:opr23hacfx5vklcq@news-text.blueyonder.co.uk...
> <snip>[color=green]
>> document.formName.Exp_Month.selectedIndex[/color]
> <snip>[color=green]
>> [1] You can also use a collection-oriented accessor method. It is
>> slightly slower and more to type, but can be used to access ID'd
>> elements, and elements with names that include characters that
>> are interpreted as operators in JavaScript (+, -, [, ], *, etc).
>> The same expression would be written as:
>>
>> document.forms['formName'].elements['Exp_Month'].selectedIndex[/color]
>
> It is not the use of the collections that allows the "illegal"
> characters to be used in javascript property accessors it is the square
> bracket notation that makes it possible.[/color]
I didn't say that, nor did I (intend to) imply it.
[snip]
[color=blue]
> document["formName"].Exp_Month.selectedIndex
> document.formName["Exp_Month"].selectedIndex
> document["formName"]["Exp_Month"].selectedIndex
> document["formName"]["Exp_Month"]["selectedIndex"]
> window["document"]["formName"]["Exp_Month"]["selectedIndex"]
>
> - and the strings used in the bracket notation can hold any character
> sequence.
>
> Similarly the collections based assessors could use dot notation
> (assuming the names/IDs conformed with the identifier rules):-
>
> document.forms.formName.elements.Exp_Month.selecte dIndex[/color]
I've seen collections accessed like that, but it's usually been in badly
written, IE-only scripts so I've always ignored it. I never realised that
the bracket- and dot-notations were quite so interchangable.
Mike
--
Michael Winter
M.Winter@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)