Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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?

irt.org | Knowledge Base | JavaScript | Form | Q1447 [ previous next ]

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?

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

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.