faqts : Computers : Programming : Languages : Asp : ASP/VBScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

209 of 264 people (79%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

HOWTO: Uncheck a Radio Button

Nov 27th, 2007 08:03
Ronald Avendaņo, Marcelo Coelho, baladitya ganty, Sue Crocker,


The easy way by Ronald Avendaņo ( [email protected] ):
It works on Firefox & IE.
<script language="JavaScript">
<!--
function unCheckRadio(oRadio) {
	  var or = document.getElementsByName(oRadio);
      for (var i = 0; i < or.length; i++) {
         or[i].checked = false;
     }
}
//-->
</script>
How to call it with a name of the radio
<a href="javascript:unCheckRadio('radio1');">Uncheck Radio radio1</a>
Another way by other Author
See this sample (works in IE3+ and NE3+):
<form name=form1 action="yourscript.asp" method=post>
     <input type=radio name=radio1 value="Big" selected>Big
     <input type=radio name=radio1 value="Small">Small
     <br>
     <input type=submit value="Post Form">
     <input type=button value="Clear All Radio Buttons" 
     onClick="clear_radio_buttons();">
</form>
<script language="JavaScript">
<!--
function clear_radio_buttons() {
     for (var i = 0; i < document.form1.radio1.length; i++) {
          document.form1.radio1[i].checked = false;
     }
}
//-->
</script>
This sample should work with checkboxes too.



© 1999-2004 Synop Pty Ltd