Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #7525

Re: Syntax for resetting radio button to initial value?

Message-ID <1564288.iOOA0IyIL1@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2011-10-18 10:45 +0200
Subject Re: Syntax for resetting radio button to initial value?
Newsgroups comp.lang.javascript
References <j7fhjv$btu$1@dont-email.me> <4e9c0e71$0$28585$a8266bb1@newsreader.readnews.com> <j7hsaq$1gr$1@dont-email.me>
Followup-To comp.lang.javascript

Followups directed to: comp.lang.javascript

Show all headers | View raw


Garry Jones wrote:

> "Denis McMahon"  wrote in message
> news:4e9c0e71$0$28585$a8266bb1@newsreader.readnews.com...

It's attribution _line_, not attribution novel.
 
> Then change:
> <input type="radio" name="r1" value = "0"> No Thanks<br>
> to:
> <input type="radio" name="r1" value = "0" id="someUniqueId"> No Thanks<br>
> and then use the javascript:
> document.getElementById("someUniqueId").checked = true;
> 
> Yes, brilliant. That did it.

There is nothing brilliant about it.  This way you will have to put an ID 
for the default radiobutton in each radiobutton group, that you must not 
have used elsewhere, when you could have simply used the radiobutton group 
name to refer to the first (or whatever) radiobutton of that *particular* 
form, and you will have search for it by document.getElementById() in the 
*whole* document.  Even the `defaultValue' approach is smarter than that.

> My problem is there are two ways to reset the form. The user can have
> called in the form from different places and the initial radio button
> value is a user value. So a form reset just resets to the initial user
> value whilst this code is just what I needed and it resets the form to a
> global default value for the user to start again.

It is generally a bad idea to allow a user reset a form.  They rarely need 
it, and often do it accidentally, losing all their input.

Regardless, if you did the form well, reset() would have sufficed.
 

PointedEars
-- 
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
  -- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk>

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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