Jump to content

Clearing Radios and Checkboxes

Recommended Posts

.checked=false; // Set either true or false the checked property

...a complete implementation is seen here:

<script type="text/javascript">var inps;window.onload=function(){inps=document.getElementsByTagName('input');for(var i=0;i<inps.length;i++){if(inps[i].type=='button'){inps[i].onclick=function(){for(var i=0;i<inps.length-1;i++){inps[i].checked=false; //This unchecks the checkbox/radioboxes. Set to true for the other way}}}}}</script><input type="checkbox"><input type="checkbox"><input type="checkbox"><input type="radio" name="myradio"><input type="radio" name="myradio"><input type="radio" name="myradio"><input type="checkbox"><input type="checkbox"><input type="checkbox"><input type="radio" name="myradio1"><input type="radio" name="myradio1"><input type="radio" name="myradio1"><br><input type="button" value="Unset">

You might find this link useful:http://www.quirksmode.org/js/forms.htmlHope it helps.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...