I’ve written an extremely simple Javascript function. All it does is randomly selects an image filename (file.png, for example) and and passes it over with getElementById.
var nameA=fileNames[randnumA];
document.getElementByID("image1").firstChild.nodeValue= nameA;
Of course, there’s other stuff to go along with that, but I didn’t feel it necessary to be included. All I’m doing is passing a string over from Javascript. Simple enough.
The problem is that I want to use that string as the source for an HTML tag. I’m a noob, and haven’t done this before, so a simple explanation would be awesome. My current code in HTML is this:
<img src=<span id="image1"> </span>>
I didn’t expect it to work, as placing tags within other tags doesn’t feel right.
Any ideas as to how I’m supposed to do this? Thanks everybody, I appreciate the help.
Also, the function is definitely being called. I have it as an onLoad in the <body> tag.
blank stare
JS: