I have created a select option:
<select>
<option value="samsung">Samsung</option>
<option value="apple">Apple</option>
<option value="lg">LG</option>
<option value="htc">HTC</option>
</select>
Later in the code, I have:
<div class="col-lg-6 text-center"> <!-- bootstrap stuff -->
<img id="changePictureYo" src="Slike/uredjajS1.png"/>
</div>
I want the img src to change depending on the selected option. (So if I select Apple, the img src would change to Slike/iphone.png).
I have tried this:
<select>
<option value="samsung">Samsung</option>
<option value="apple" onselect="changeImage()">Apple</option>
<option value="lg">LG</option>
<option value="htc">HTC</option>
</select>
And in my .js file:
function changeImage() {
document.getElementById("changePictureYo").src = "Slike/iphone.png";
}
But it is not working. What am I missing?