3
When I select a select option I would have a different image appear in the img I created, but it’s not working.
HTML code
<select id="produtos" onchange="mudaFoto()">
<option value="">Selecione o Produto</option>
<option value="ac-uniao">Áçúcar Refinado união</option>
<option value="ac-guarani">Áçúcar Refinado Guarani</option>
<option value="AM">AM</option>
</select>
Javascript code
var foto = document.getElementById('imagem-produto').src;
function mudaFoto() {
switch(document.getElementById('produtos').selectedIndex()) {
case 1: foto = "_imagens/acucar-uniao.png";
break;
}
}
I made the changes exactly the same, but it’s not entering the switch, I tried the case 1 with alerte and it’s not working yet.
– Igor Ramos
I arranged the switch for more options and switched the images for the test, look: http://jsbin.com/busepuma/1/edit
– Gustavo Rodrigues
Good explanation. + 1
– Sergio