Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #7557
| From | Dr J R Stockton <reply1142@merlyn.demon.co.uk> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Syntax for resetting radio button to initial value? |
| Date | 2011-10-18 20:50 +0100 |
| Organization | Home |
| Message-ID | <meRGu+GgidnOFwv2@invalid.uk.co.demon.merlyn.invalid> (permalink) |
| References | <j7fhjv$btu$1@dont-email.me> |
In comp.lang.javascript message <j7fhjv$btu$1@dont-email.me>, Sun, 16
Oct 2011 23:16:48, Garry Jones <garry@garryjones.se> posted:
>I have a reset function for a user form which clears text fields,
>resets drop down boxes to initial values and moves focus to first input
>field.
>
>However I need to reset radio buttons to their inital value (of zero).
Radio buttons have Boolean values. Initially, all of a set are false,
unless the HTML includes "checked". The reader can select any one, but
not none. The coder can set any one, but not (or not necessarily) none.
>The bit I am stuck with is
>
>if (elements[i].checked) {
> elements[i].checked = false;
>}
There is no need to check that something is on before setting it off.
One cannot turn a radio button off (at least, not in all browsers); but
one can turn another one of the set on, which clears it colleagues.
If you want to set a set of N radio buttons all to off, then create
button N+1 and turn that on, by code as author or by click as user.
Button N+1 can be marked as readonly (maybe), disabled,
visibility:hidden, display:none, depending on author's preference.
Author may prefer to use Button 0 for that.
--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike 6.05 WinXP.
Web <http://www.merlyn.demon.co.uk/> - FAQ-type topics, acronyms, and links.
Command-prompt MiniTrue is useful for viewing/searching/altering files. Free,
DOS/Win/UNIX now 2.0.6; see <URL:http://www.merlyn.demon.co.uk/pc-links.htm>.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar
Syntax for resetting radio button to initial value? "Garry Jones" <garry@garryjones.se> - 2011-10-16 23:16 +0200
Re: Syntax for resetting radio button to initial value? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2011-10-17 00:46 +0300
Re: Syntax for resetting radio button to initial value? dhtml <dhtmlkitchen@gmail.com> - 2011-10-16 22:56 -0700
Re: Syntax for resetting radio button to initial value? Matt McDonald <matt@fortybelow.ca> - 2011-10-16 16:49 -0600
Re: Syntax for resetting radio button to initial value? dhtml <dhtmlkitchen@gmail.com> - 2011-10-16 22:57 -0700
Re: Syntax for resetting radio button to initial value? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-17 09:56 +0200
Re: Syntax for resetting radio button to initial value? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-17 09:51 +0200
Re: Syntax for resetting radio button to initial value? Denis McMahon <denismfmcmahon@gmail.com> - 2011-10-17 10:56 +0000
Re: Syntax for resetting radio button to initial value? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-17 14:32 +0200
Re: Syntax for resetting radio button to initial value? Denis McMahon <denismfmcmahon@gmail.com> - 2011-10-17 11:16 +0000
Re: Syntax for resetting radio button to initial value? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-17 14:45 +0200
Re: Syntax for resetting radio button to initial value? "Garry Jones" <garry@garryjones.se> - 2011-10-17 20:31 +0200
Re: Syntax for resetting radio button to initial value? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-18 10:45 +0200
Re: Syntax for resetting radio button to initial value? Dr J R Stockton <reply1142@merlyn.demon.co.uk> - 2011-10-18 20:50 +0100
csiph-web