Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

Q521 Can I change the selection in the select box by clicking on a link?

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


<script language="JavaScript"><!--
function changeSelect(x) {
    document.myForm.mySelect.selectedIndex = x-1;

<form name="myForm">
<select name="mySelect">
<option>Option 1
<option>Option 2
<option>Option 3
<option>Option 4

<a href="javascript:changeSelect(1)">Change it to 1</a>
<a href="javascript:changeSelect(2)">Change it to 2</a>
<a href="javascript:changeSelect(3)">Change it to 3</a>
<a href="javascript:changeSelect(4)">Change it to 4</a>

©2018 Martin Webb