Solved

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

Posted on 2011-09-26
3
160 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
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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

789 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