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

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

irt.org | Knowledge Base | JavaScript | Image | Q900 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


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