Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1712 How can I disable a group of radio buttons?

You are here: irt.org | FAQ | JavaScript | DHTML | Q1712 [ previous next ]

The following works in HTMl 4.0 enabled browsers:

<script language="JavaScript"><!--
function disableGroup(formName, groupName, booleanDisabled) {
  for (var i=0; i<formName.elements.length; i++) {
    if (formName.elements[i].name == groupName) {
      formName.elements[i].disabled = booleanDisabled;
    }
  }
}
//--></script>

<form>
<input type="radio" name="grp1">
<input type="radio" name="grp1">
<input type="radio" name="grp1">
<input type="radio" name="grp1">
<input type="radio" name="grp1">

<input type="button" value="Disable" onClick="disableGroup(this.form, 'grp1', true)">
<input type="button" value="Enable" onClick="disableGroup(this.form, 'grp1', false)">
</form>

Feedback on 'Q1712 How can I disable a group of radio buttons?'

©2018 Martin Webb