On Aug 10, 2:56 pm, Hendri Kurniawan <hckurnia...@gmail.comwrote:
On Aug 10, 2:10 pm, RobG <rg...@iinet.net.auwrote:
On Aug 10, 1:18 pm, Hendri Kurniawan <hckurnia...@gmail.comwrote:
[...]
I am assuming that you want to find out the number of options in the
select element.
getElementById('form3')['members[]'].options.length =
username.length;
Note the "options"
Why? The select element itself has a length property which is equal to
the number of options.
<URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-5933486>
--
Rob
Hmm you are right. never tried that before. Always options...
Well I should revoke my answer then.
I'm now GUESSING that the elements returned from
getElementById('form3')['members[]']
is actually an array of elements (by where he have multiple
'members[]' elements.
No need to guess, read the spec:
"Returns the Element whose ID is given by elementId. If no such
element exists, returns null. Behavior is not defined if more than one
element has this ID."
<URL:
http://www.w3.org/TR/DOM-Level-2-Cor...ml#ID-getElBId >
getElementById should not return more than one element, though if more
than one element has the same ID (which would be invalid for HTML), it
seems the first will be return though I wouldn't ever depend on that.
If the element is a select, then it will have an options property,
which is an HTML collection (NodeList), not an Array.
<URL:
http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-30606413 >
--
Rob