Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <1930014.TA4aT0qaH3@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Tue, 19 Nov 2013 19:55:15 +0100 User-Agent: KNode/4.10.5 Content-Transfer-Encoding: 8Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. <528b9f28$0$9502$9b4e6d93@newsspool1.arcor-online.net> MIME-Version: 1.0 Lines: 43 NNTP-Posting-Date: 19 Nov 2013 19:55:28 CET NNTP-Posting-Host: 6caa75c1.newsspool1.arcor-online.net X-Trace: DXC=VT6h>hiML>7TQL:hoD@>T?ic==]BZ:af>4Fo<]lROoR1nkgeX?EC@@0\BGGOn[Md>8DZm8W4\YJN:8@l47Y;\C?FaA75 X-Complaints-To: usenet-abuse@arcor.de Xref: csiph.com comp.lang.javascript:22072 Christoph Michael Becker wrote: > Bart Van der Donck wrote: >> Say the following code: >> >>
>> >> There are two 'official' ways to read out the current selected >> value: >> >> document.getElementById('myID').value >> document.f.myName.options[document.f.myName.selectedIndex].value > > It seems reasonable to distinguish between referencing the form element > and accessing its value. The latter is explained in this NG's FAQ[1], > the former in a side note to the FAQ[2]. However, the “official“, i.e. *both* standards-compliant and backwards- compatible approach is var el = document.form["f"].elements["myName"]; el.options[el.selectedIndex].value but it only works for el.type == "select-one", and it is necessary to check that el.selectedIndex is not out of bounds; at least, that it is not negative. >> But I can't find any reasonable environment where the following >> fails: >> >> document.f.myName.value > > As explained in the FAQ[1], this would fail under NN4, for instance. It also fails under certain circumstances in IE/MSHTML. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.