Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #22080
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2013-11-20 02:40 -0800 |
| References | <7fc7ae95-94ad-4c65-9596-3a63d245360e@googlegroups.com> <l6g7bo$r0h$1@dont-email.me> |
| Message-ID | <ff2e6fbf-0209-4a1b-bc79-372da7ff3c98@googlegroups.com> (permalink) |
| Subject | Re: Syntax to access the selected option's value |
| From | Bart Van der Donck <bart@nijlen.com> |
Jukka K. Korpela wrote:
> "The value IDL attribute [of a select element], on getting, must return
> the value of the first option element in the list of options in tree
> order that has its selectedness set to true, if any. If there isn't one,
> then it must return the empty string."
> http://www.w3.org/TR/html5/forms.html#dom-select-value
That's the hyperlink I was looking for, thanks. I think you're right; one shouldn't expect "document.f.myName.value" to fail. But still, other approaches are more recommended/traditional, maybe the classic forms[x].elements[y] on top. But there is more than one way to do it.
I would even go a step further. Under the initial hypothesis that "document.getElementById('myID').value" is 'official', "document.f.myName.value" must be 'official' as well. W3 only speaks vaguely about "getting" the value-attribute. Nothing is said about whether the value-attribute should be accessed by ID or NAME, and, in both cases, how then.
--
Bart
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Syntax to access the selected option's value Bart Van der Donck <bart@nijlen.com> - 2013-11-19 06:20 -0800
Re: Syntax to access the selected option's value "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-11-19 08:27 -0800
Re: Syntax to access the selected option's value Christoph Michael Becker <cmbecker69@arcor.de> - 2013-11-19 18:26 +0100
Re: Syntax to access the selected option's value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-19 19:55 +0100
Re: Syntax to access the selected option's value Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-11-19 19:18 +0000
Re: Syntax to access the selected option's value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-19 22:48 +0100
Re: Syntax to access the selected option's value "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-11-19 19:32 +0200
Re: Syntax to access the selected option's value Bart Van der Donck <bart@nijlen.com> - 2013-11-20 02:40 -0800
Re: Syntax to access the selected option's value Christoph Michael Becker <cmbecker69@arcor.de> - 2013-11-21 22:27 +0100
csiph-web