I am currently in the process of trying to create a pokedex app and have a dropdown with each pokemon's name then have a corresponding image for that pokemon above, then will change when a new one is selected.
I am having trouble as the image isn't changing currently.
This is what I have so far. I have a default picture of a pokeball but can't seem to get it to change when the next item is selected. Any help is much appreciated.
var changePokemonImage = function() {
document.getElementById('image').src = this.options[this.selectedIndex].value
}
var pokemonList = document.getElementById('pokemonList');
pokemonList.addEventListener('change', changePokemonImage, false);
<br>
<img id="image" src="PokeBall_Image.png" />
<br>
<br>
<select id="pokemonList">
<option value="Please Select A Pokemon">Please Select A Pokemon:</option>
<option value="Bulbasaur">Bulbasaur</option>
</select>
srcattribute to thevalueof the selected option ("Bulbasaur"), but this is resulting in a 404 error. You'll need some logic to specify an image based on the selected value, either a switch statement, or adata-srcattribute on each option, etc. JSFiddle for reference: jsfiddle.net/whLjax02