Try this function out:
Code:
/**
* @class window
*
* @function disableRadioGroups
* Searches through all the FORMs on the page and disables groups of radio
* buttons if one of them is checked.
*
* @param void
* @return void
*/
function 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;
}
}
}
}
}
}
window.onload = function() {
disableRadioGroups();
};
Bookmarks