[TriLUG] Stuck in a rut
Brian McCullough
bdmc at bdmcc-us.com
Tue Sep 15 17:20:15 EDT 2009
On Tue, Sep 15, 2009 at 04:21:52PM -0400, Michael Peters wrote:
> On 09/15/2009 04:08 PM, Brian McCullough wrote:
>
>> var name = 'ex-' + counter;
>> var len = document.example.name.length;
>
> Yeah that won't work because it's treating "name" as the method "name".
> You should remember that all JS objects are also associative arrays, so
> you can use that string (in the variable "name") as the key:
>
> var name = 'ex-' + counter;
> var len = document.example.elements[name].length;
Thank you, Michael. That's the syntax that I was trying to remember, and not finding in my searches, either.
I spent some time with "null" and "undefined", as well. Isn't it fun when you get a value back from a function, read it with alert, and think that "null" means "null"? Actually, what I was getting back was the string "null", not the value null!
Thanks for the help,
Brian
More information about the TriLUG
mailing list