I want to change the <img src> with value from my <select>.
I have the next HTML code:
<img id="fotosel" /><br/>
<select id="cmbfotos" onchange="aplicarFoto()">
<option value="gokussj3.jpg">Goku SSJ3</option>
<option value="gokussj4.jpg">Goku SSJ4</option>
<option value="gohanssj2.jpg">Gohan SSJ2</option>
<option value="gotenks.jpg">Super Gotenks</option>
<option value="krilin.jpg">Krilin</option>
</select>
and Javascript code:
var fotosel = document.getElementById("fotosel");
var cmb = document.getElementById("cmbfotos");
function aplicarFoto(){
fotosel.src = "fotos/"+cmb.options[cmb.selectedIndex].value;
}
But that doesnt work. I made a test putting an alert() with cmb.options[cmb.selectedIndex].value and nothing appears.
Some guess? Thank you!