I want to randomly generate an src path for an image, for example;
src = <var1>/<var2>.gif
I'm sure it can be done, but not sure at what level it would go in. This is what I have;
var huePick =[{text:'light',image:'light'},{text:'dark',image:'dark'}];
var colourPick =[{text:'green',image:'green.gif'},{text:'red',image:'red.gif'}];
function myFunction() {
var hueChosen= huePick [Math.floor(Math.random()*huePick.length)];
var colourChosen= colourPick [Math.floor(Math.random()*colourPick.length)];
document.getElementById("thisResult").src = hueChosen.image / colourChosen.image; }
The id called 'thisResult' I want to be able to use as a url I can drop into an image tag. Which would look like this; dark/green.gif and locate the relevant image in the relevant folder. (I know I could reference them all in one folder with one long variable but I have reasons why not to)
How do I arrange the getElementById string and implement it into an image tag?
Does any of that make sense?
(Obviously I would have a corresponding file structure with different gifs in the light folder to those in the dark folder, but with same names.)