?
Solved

How can I clear all the radio buttons on a form?

Posted on 2011-09-26
3
Medium Priority
?
172 Views
Last Modified: 2012-05-12
I have a group of radio buttons named "LIST.VAR3_RADIO" that I need to clear when a dropdown list called "VAR29_1" is selected.

I assume it would be best to do this with javascript?

Any help would be appreciated.
0
Comment
Question by:Donnie Walker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Expert Comment

by:afsarsal
ID: 36599388
Hi,

You can call this function;

function clearAllRadioButtons() {
var radList = document.getElementsByName('radioList');
for (var x = 0; x < radList.length; x++) {
if(radList[x].checked) radList[x].checked = false;
}
}
0
 
LVL 13

Accepted Solution

by:
ansudhindra earned 2000 total points
ID: 36599431
check this...
 
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title> - jsFiddle demo</title>
  <script type='text/javascript' src='http://code.jquery.com/jquery-1.6.3.js'></script>
  
  <link rel="stylesheet" type="text/css" href="/css/normalize.css">
  <link rel="stylesheet" type="text/css" href="/css/result-light.css">
  
  <style type='text/css'>
    
  </style>
  
  <script type='text/javascript'>
  //<![CDATA[ 
  $(window).load(function(){
  $('#sel').change(function(){
    $(".rad").each(function () {
                this.checked=false;
              });
});
  });
  //]]> 
  </script>
  
</head>
<body>
  <select name="sel" id="sel">
    <option value="1">Reset All 1</option>
    <option value="1">Reset All 2</option>
</select><br><br>
<input type="radio" name="rcb1" class="rad" value="1" />&nbsp;Group 1 - R1<br>
<input type="radio" name="rcb1" class="rad" value="1" />&nbsp;Group 1 - R2<br>
<input type="radio" name="rcb2" class="rad" value="1" />&nbsp;Group 2 - R1<br>
<input type="radio" name="rcb2" class="rad" value="1" />&nbsp;Group 2 - R2<br>
<input type="radio" name="rcb3" class="rad" value="1" />&nbsp;Group 3 - R1<br>
  
</body>


</html>

Open in new window


url..
http://jsfiddle.net/Sudhindra/95xMp/

BR-Sudhindra-www.clicksperday.com
0
 

Author Closing Comment

by:Donnie Walker
ID: 36599734
Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question