I know this is probably not complicated but I can't figure it out. Can someone point me to how you make a different image appear (replacing the original) on a page with each time the page is refreshed?
If you're refreshing something like an asp or php page, you would have some sort of server-side script that works out what the most current picture is and insert the file name into the <img src="" /> tag during the refresh.
A simple alternative to this (especially if the image is something like a whatever-cam photo) is to just have whatever is producing the images overwrite the previous image as it updates. This way, every time the web page refreshes, it gets the most current image.
SELECT user
FROM users
WHERE common_sense IS EQUAL TO NULL;
Yet another option is to do it client side with Javascript.
Set up an array with the names of possible images, then write out the HTML with the appropriate filename in.
That is assuming the client has JavaScript enabled in their browser.
If you choose this method there are plenty of ready made scripts out there. Try
If you're just interested in selecting a semi-random picture from an array of pictures, you can go off this:
Code:
var now = new Date();
var ms = now.getMilliseconds();
var picArray = new Array(25); //fill this with your pix
var randomIndex = ms % picArray.length; //mod arithmetic
Then, set SRC of the IMG of your choice to picArray[randomIndex].
It's not "strictly" random, but it should ensure a better a reasonable probability of not getting the same image twice in a row.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.