MattsBits
MattsBits

MattsBits

Javascript Function To Clear Radio Buttons  

by Matt Hawkins, 05/11/2010
Categories : JavaScript

Once a radio button has been selected there is no way for the use to reset the selection and select nothing. This javascript function clears the radio buttons for a radio group with a name of 'radName'.

Note : This does not work if the radio group is an array.

<script language="JavaScript" type="text/javascript">
<!--
function clear_radio(radName){

' This function clears the radio buttons for the
' radio group with a name of radName

var radio = document.getElementsByName(radName);
for(var i = 0; i < radio.length; i++){
if(radio[i].checked === true){
radio[i].checked = false;
}
}
}
//-->


Note : This does not work if the radio group is an array.

Author : Matt Hawkins  Last Edit By : Matt Hawkins
PHP Powered  MySQL Powered  Valid XHTML 1.0  Valid CSS  Firefox - Take Back The Web  EUKHost - Recommended Webhosting Solutions

MattHawkins CMS v3.0 - Copyright 2009-2022