How do I get a different image every time I refresh? Also I want each image to be linked to a page on my website
Add a new collection with 2 columns: 1 for each of your images and 1 for reference numbers.
Use new Date() function to create a random number.
(comes in format 12/9/2020, 6:10:06 PM)
Use substr function to extract the appropriate characters from the current time (this will vary based on the number of images you have, if less than 10 you would extract the last digit that indicates seconds, if it’s less than 60 you would extract the last 2 digits, etc)
From there you can write the code to fetch the image from the collection depending on the number created by the substring of the date variable. You would use the image element’s .src function to set the corresponding image
You will also have to probably specify a range (e.g. if the number generated is 10-15, select image 2 from the collection) because I doubt you have exactly 10 or exactly 60 images
Here’s another easier method for random number generation:
https://www.wix.com/corvid/forum/community-discussion/random-number-generator
Play around with the Random Image example.
Hello everyone,
really struggling with figuring this out, is there someone who could write down the code for me to paste into my website?
I’ve looked for alternatives but this is really what i’m looking to use!
I’d be very thankful for any kind of help! ::