Jens Holzkämper: Warum ist SelectedIndex nicht -1

Beitrag lesen

Tach,

Im Quellcode bei mir ist nirgends etwas wie "selected" drin. Auch wird per Javascript nirgends der Index gesetzt.

ob und welches selektiert ist, wenn es kein selected gibt, ist in HTML 4 undefiniert und dem Browser überlassen:

"If no OPTION element has the selected attribute set, user agent behavior for choosing which option is initially selected is undefined. Note. Since existing implementations handle this case differently, the current specification differs from RFC 1866 ([RFC1866] section 8.1.3), which states:
The initial state has the first option selected, unless a SELECTED attribute is present on any of the <OPTION> elements.
Since user agent behavior differs, authors should ensure that each menu includes a default pre-selected OPTION." - http://www.w3.org/TR/html401/interact/forms.html#h-17.6.1

mfg
Woodfighter