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

Q900 Is it possible to have each option of a select in a form perform an image swap?

You are here: irt.org | FAQ | JavaScript | Image | Q900 [ previous next ]

Yes - using the onChange event handler:

<script language="JavaScript"><!--
function swap(source) {
    if (document.images) {
        document.images['myImage'].src = source;
    }
}
//--></script>

<img src="image.gif" name="myImage" width="100" height="100">

<form>
<select onChange="swap(this.options[selectedIndex].value)">
<option value="image0.gif">Show image 0
<option value="image1.gif">Show image 1
<option value="image2.gif">Show image 2
<option value="image3.gif">Show image 3
</select>
</form>

Feedback on 'Q900 Is it possible to have each option of a select in a form perform an image swap?'

©2018 Martin Webb