Solved

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

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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…
Suggested Courses

624 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