I'm trying to retrieve images from a local file by appending .jpg to a string. The web pages is a dictionary so I take the current available word from a different location in the html. Is there anyway to then output a link to the image from the javascript? This is what I have tried so far.
JavaScript:
function getImage () {
x = document.getElementById("word").innerHTML;
image = "images/" + x + ".jpg";
return image;
}
HTML:
<div>
<img id="circle" src="getImage()" alt="image">
</div>
I'm retrieving "word" with an xmlhttprequest that ends like this
var item = xmlDoc.getElementsByTagName("word")[i].childNodes[0];
document.getElementById("word").innerHTML = item.nodeValue;