(Canceled my other posting, consider it obsolete.)
Thomas 'PointedEars' Lahn said:
Michael said:
Use the 'options' array:
multipleSelectElement.options[ index ].selected = boolean;
`options' is _not_ an Array (object), it is an
HTMLOptionsCollection object or more generally a collection. You
can access the options *like* an array (using the index operator),
but not *as* an array [i.e. you can't do ...options.join(''), for
example].
It is an "array".
It is not an "Array".
According to ECMAScript(-3) there are no primitive array values in the
language:
| 4.3.2 Primitive Value
|
| A primitive value is a member of one of the types Undefined, Null,
| Boolean, Number, or String. A primitive value is a datum that is
| represented directly at the lowest level of the language
| implementation.
Thus there should not be one in ECMAScript(-3) implementations. In
JavaScript (1.5), there is not:
,-<
http://devedge.netscape.com/library/manuals/2000/javascript/1.5/guide/obj.html#1008453>
|
| Array Object
|
| JavaScript does not have an explicit array data type. However, you can
| use the predefined Array object and its methods to work with arrays in
| your applications.
| [...]
| To create an Array object:
|
| 1. arrayObjectName = new Array(element0, element1, ..., elementN)
| 2. arrayObjectName = new Array(arrayLength)
| [...]
| Array literals are also Array objects; for example, the following
| literal is an Array object. [...]
|
| coffees = ["French Roast", "Columbian", "Kona"]
Let's test it (using Mozilla/5.0):
alert(new Array(1, 2, 3)); // "1,2,3" (because of
alert([1, 2, 3]); // "1,2,3" Array.toString())
alert(typeof new Array([1, 2, 3])); // "object"
alert(typeof [1, 2, 3]); // "object"
alert(new Array(1, 2, 3).join("|")); // "1|2|3"
alert([1, 2, 3].join("|")); // "1|2|3"
alert([1, 2, 3].constructor); /*
* "function Array() {
* [native code]
* }"
*/
alert(new Array(1, 2, 3).constructor); /*
* "function Array() {
* [native code]
* }"
*/
The constructor of object referenced by the `options' property of
HTMLSelectElements objects is not Array but HTMLOptionsCollection
(or a derivative of it), and it lacks the most properties of the
Array prototype, so it is _not_ an /[Aa]rray( object)?/ but a
collection. You can access elements of the collection with the
index operator `[...]', like you can with elements of an
/[Aa]rray( object)?/, *if* the index in the latter case is numeric
(there are no associative arrays in JavaScript, these are Array
objects having additional properties.)
PointedEars