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


Groups > comp.lang.javascript > #7512

Re: Syntax for resetting radio button to initial value?

From "Garry Jones" <garry@garryjones.se>
Newsgroups comp.lang.javascript
Subject Re: Syntax for resetting radio button to initial value?
Date 2011-10-17 20:31 +0200
Organization A noiseless patient Spider
Message-ID <j7hsaq$1gr$1@dont-email.me> (permalink)
References <j7fhjv$btu$1@dont-email.me> <4e9c0e71$0$28585$a8266bb1@newsreader.readnews.com>

Show all headers | View raw


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

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.

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.

I am very thankful to everyone who posted. I am fairly home in php and sql 
but quite limited in javascript, I usually google pieces of code and adapt 
them to suit my needs. Biggest problem with this Crome, Safari, Firefox, 
Opera and MSIE treat javascript code differently and whilst php, sql etc 
behave the same everywhere I find javascript to be a pain, its like allowing 
foreign drivers to drive on the same side of the road as they do back home 
and building a road system to allow this. Anyway, gripe over, I'm happy and 
think its wonderful USENET can still outgun message boards and FAQ's in 
2011.

Garry Jones
Expat in Sweden

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