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] Quote Link to comment 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] Quote Link to comment 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? Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
emehrkay Posted December 30, 2006 Share Posted December 30, 2006 is radioGroup defined? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.