Mega Code Archive

 
Categories / JavaScript Tutorial / Form
 

Radio defaultChecked

The defaultChecked property is a Boolean value that reports which radio buttons contain the HTML CHECKED attribute. If the CHECKED attribute is contained in the Radio object, true is returned. Otherwise, false is returned. <html>     <head>     <title> Example of the radio defaultChecked property</title>     </head>     <body>     <script language="JavaScript">     <!--     function checkBox(){         if(document.form1.button1.defaultChecked == true){             alert("Box1 is checked by default");         } else if(document.form1.button2.defaultChecked == true){             alert("Box 2 is checked by default");         }     }     -->     </script>     <form name="form1">     <input type="radio" name=button1>Box 1     <br>     <input type="radio" name=button2 CHECKED>Box 2     <br><br>     <input type="button" value="Get Default" onClick='checkBox()'>     </form>     </body>     </html>