NickG21 Posted December 29, 2006 Share Posted December 29, 2006 hey everyone im looking to disable a group of radio buttons and a group of checkboxes if one checkbox is checked at the beginning of the site. i have put up a few posts so i apologize for any repitition just trying to see if there is anyone else on here who could give me a little insight? right now here is the function i have to do the work but it doesn't work. also, i am extremely new at this so any help is much appreciatedthank you[CODE]<!--function DisableRadioGroup(radioGroup, disable){ if(document.forms["form1"].elements["OwnersManual"].checked){ for(var i=0; i < radioGroup.length; i++) { radioGroup[i].disabled = false } }else{ for(var i=0; i < radioGroup.length; i++) { radioGroup[i].disabled = true }}}//-->[/CODE] Link to comment https://forums.phpfreaks.com/topic/32211-enabledisabe-button-group/ Share on other sites More sharing options...
paul2463 Posted December 29, 2006 Share Posted December 29, 2006 your if statement seems to be incorrect, I am not all that good with javascript but you could try this[code]<!--function DisableRadioGroup(radioGroup, disable){ if(document.getElementById("OwnersManual").checked == true){ for(var i=0; i < radioGroup.length; i++) { radioGroup[i].disabled = false } }else{ for(var i=0; i < radioGroup.length; i++) { radioGroup[i].disabled = true }}}//-->[/code]and I take it this function is called in the onclick event of the checkbox??[code]<INPUT TYPE=checkbox ID="OwnersManual" onclick="DisableRadioGroup(radioGroup, disable)">[/code] Link to comment https://forums.phpfreaks.com/topic/32211-enabledisabe-button-group/#findComment-149514 Share on other sites More sharing options...
NickG21 Posted December 29, 2006 Author Share Posted December 29, 2006 that looks better than mine for sure and with a few minor adjustments worked perfectly, one more thing, is there anyway to implement a group of checkboxes as well or do i have to go through and individually make them disable after the box is checked? Link to comment https://forums.phpfreaks.com/topic/32211-enabledisabe-button-group/#findComment-149524 Share on other sites More sharing options...
michaellunsford Posted December 30, 2006 Share Posted December 30, 2006 you'll probably have to scan through the form and disable checkboxes one by one. Here's an example I made where any checkbox who's "name" starts with "somebox" would be disabled.[code]f = document.forms["form1"];for (i = 0 ; i < f.elements.length; i++) { if ((f.elements[i].type == "checkbox") && (f.elements[i].name.substring(0,7) == "somebox")) f.elements[i].disabled=true;}[/code] Link to comment https://forums.phpfreaks.com/topic/32211-enabledisabe-button-group/#findComment-149688 Share on other sites More sharing options...
emehrkay Posted December 30, 2006 Share Posted December 30, 2006 is radioGroup defined? Link to comment https://forums.phpfreaks.com/topic/32211-enabledisabe-button-group/#findComment-149890 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.