Am a bit desperate and try to find a solution to the following problem:
- When using spinning wheel or giftbox I often have to create new lander when the prize image is different --> lander with iPhone image, with S20 image, with Aldi giftcard etc...
- So each time have a new prize to win I upload new lander on server and change the image files
How to automate?
My idea is to pass the prize image file name via URL parameter. So I would just need to upload new prize image to an existing lander.
What I have tried:
<script>function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] || ''
);
}
</script>
<script> var image_path = document.write(getURLParameter("pic")); </script>
<img class="prizeImg" src=image_path alt="" style="width:60%; margin-left: 20%">

Hey,
Give an ID attribute to your image, and then use getElementbyId if you have one image only.
<img class="prizeImg" id="prizeImg1" src="" alt="">
<script>document.getElementbyId("prizeImg1").src = getURLParameter("pic");</script>
I also just tested but didn´t get it running but good ol´ jeremie never disappoints 
Your part to get the pic url seeems ok. Be sure to include the relative url in the var, or to hardcode it. For example, if all your images are jpg in the /images/
And if you are not sure you pass the variable correctly, you can use the dev console to display it and check. Remove the console.log when you have finished.
console.log(getURLParameter("pic"));
document.getElementbyId("prizeImg1").src = "/images/" + getURLParameter("pic") + ".jpg" ;
Thank you jeremie for your speedy reply.
Have included the code at the place where the og line was for posting the pic. The image file is in same directory as the index.html is.
This line made the picture appear:
<img class="prizeImg" src="black.png" alt="" style="width:60%; margin-left: 20%">


Hey,
The method I mentioned work on a server. It might not work when testing on your computer.
Also, make sure the images are on the same domain
Here is a full code running that I just wrote and tested
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<img class="prizeImg" id="prizeImg1" src="" alt="">
<img class="prize" src="" alt="">
<img class="prize" src="" alt="">
<script>
var img_name = getURLParameter("pic");
/* Single Image -- getElementbyId */
var img_cl = "prizeImg1";
document.getElementById(img_cl).src = img_name;
/* Multiple Images -- getElementsByClassName */
var imgs_cl = "prize";
var imgs = document.getElementsByClassName(imgs_cl);
for (i = 0; i < imgs.length; i++) {
imgs[i].src = img_name;
}
function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || [, null])[1] || ''
);
}
</script>
</body>
</html>