Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-09-26
3
Medium Priority
?
176 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 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
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

927 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