Full version: jsB@nk » Form » Checkbox » Onload Disabled Radio Button Groups
URL: https://www.javascriptbank.com/onload-disabled-radio-button-groups.html
Let use this JavaScript code if you need to disable groups of radio buttons on the page when it is already loaded. This code can be setuped for many radio button groups on one page. Very easy to customize.
Full version: jsB@nk » Form » Checkbox » Onload Disabled Radio Button Groups
URL: https://www.javascriptbank.com/onload-disabled-radio-button-groups.html
<script type="text/javascript"><!--// Created by: Greg Burghardt :: http://www.webdeveloper.com/forum/showthread.php?t=158022function disableRadioGroups() { var forms, el, radioGroup; var i = end = j = elsEnd = rg = rgEnd = 0; if (document.getElementsByTagName) { forms = document.getElementsByTagName('form'); /* Loop through all the FORMs */ for (i, end = forms.length; i < end; i++) { /* Loop through each form element */ for (j = 0, elsEnd = forms[i].elements.length; j < elsEnd; j++) { el = forms[i].elements[j]; /* If this is a checked, enabled radio button in a radio group... */ if (!el.disabled && el.nodeName === 'INPUT' && el.type == 'radio' && el.checked && forms[i].elements[el.name].length) { radioGroup = forms[i].elements[el.name]; /* Loop through radio group and disable buttons */ for (rg = 0, rgEnd = radioGroup.length; rg < rgEnd; rg++) { radioGroup[rg].disabled = true; } } } } }}// Multiple onload function created by: Simon Willison// http://simonwillison.net/2004/May/26/addLoadEvent/function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } }}addLoadEvent(function() { disableRadioGroups();});//--></script>
<form>Are you a member?<br><input disabled="disabled" name="member" value="1" checked="checked" type="radio">Yes<br><input disabled="disabled" name="member" value="2" type="radio">No<br><input disabled="disabled" name="member" value="3" type="radio">I'm Not Sure<br><p>Will you attend the national event?<br><input name="conf" value="1" type="radio">Yes<br><input name="conf" value="2" type="radio">No<br></p></form>