View Full Version : Change Image with Drop Down?

11-08-2005, 08:35 PM
Greetings, folks...

I am a near-absolute javascript noob, although I do have a pretty extensive background in programming. What I'm looking to do is the following...

I'd like a drop down box that lists, for instance, colors and, just to the right of that, have a JPG of that color. When the drop down box is changed, it'll automatically load the image of the color the person has selected.

I've searched the web over for example code to do this, but haven't found anything this specific. Anyone able to lend a hand here?

11-08-2005, 09:20 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"


<script language="JavaScript" type="text/javascript">
var Path='http://www.vicsjavascripts.org.uk/StdImages/';

function CngColor(obj){
if (index<1){ return; }

<select onchange="CngColor(this);" >
<option >Select</option>
<option value="Zero.gif" >Zero</option>
<option value="One.gif" >1</option>
<option value="Two.gif" >2</option>
<option value="Three.gif" >3</option>
<option value="Four.gif" >4</option>
<img id="Img1" src="http://www.vicsjavascripts.org.uk/StdImages/Blank.gif" width=100 height=100 >