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

Q1447 How could I change whether a check box or radio button is checked depending on what the user select from a drop down list?

You are here: irt.org | FAQ | JavaScript | Form | Q1447 [ previous next ]

Try:

<script language="JavaScript"><!--
function changed(form) {
  if (form.theSelect.options[form.theSelect.selectedIndex].value == 'yes') {
    form.theRadio.checked=true;
    form.theCheckbox.checked=true;
  }
  else {
    form.theRadio.checked=false;
    form.theCheckbox.checked=false;
  }
}
//--></script>

<form>
<select onChange="changed(this.form)" name="theSelect">
<option value="no">no
<option value="yes">yes
</select>
<input type="radio" name="theRadio">
<input type="checkbox" name="theCheckbox">
</form

©2018 Martin Webb