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

Q741 How can I select an option in a select form field when a radio button is selected?

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

Try:

<SCRIPT LANGUAGE="JavaScript"><!--
function altered(what) {
    for (var i = 0;i<5; i++)
        if (what.sameName[i].checked)
            what.mySelect.options[i].selected = true;
}
//--></SCRIPT>

<FORM>
<SELECT NAME="mySelect">
<OPTION>0
<OPTION>1
<OPTION>2
<OPTION>3
<OPTION>4
</SELECT>

<INPUT TYPE="RADIO" NAME="sameName" onClick="altered(this.form)">
<INPUT TYPE="RADIO" NAME="sameName" onClick="altered(this.form)">
<INPUT TYPE="RADIO" NAME="sameName" onClick="altered(this.form)">
<INPUT TYPE="RADIO" NAME="sameName" onClick="altered(this.form)">
<INPUT TYPE="RADIO" NAME="sameName" onClick="altered(this.form)">
</FORM>

©2018 Martin Webb