On 18 February 2004 01:21, Daevid Vincent contributed these pearls of wisdom:

> Okay kids. Here's another strange one. Very simple form. The
> array is dynamically generated from PHP as per the suggested
> method:
> http://us2.php.net/manual/en/faq.html.php#faq.html.arrays 
> 
> However, when there is only a single element, the
> myMultiSelect.length is
> undefined in javascript.
> If there are two or more elements, then the length works as
> expected... 

Correct.  If there is only a single element with a name, JavaScript creates a single 
scalar checkbox property with that name; if there are multiple elements with the same 
name, it creates an array of those elements as that property.  The existence of the 
'[]' in the element name has no significance for JavaScript -- it goes solely on how 
many of the elements there are.

Checking whether the .length property exists is one way of telling whether you have a 
single element or multiple ones!

Cheers!

Mike

-- 
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to