Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

939 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now