code:You do, of course, have to manually modify the list of images, or even generate that list using php if you want.<html>
<head>
<title></title>
<script>
<!--
window.onload = function () {
img = document.getElementById("main_img");
// make a list manually here
imageList = [
"red.png",
"green.png",
"blue.png"
];
newImage = imageList[Math.floor(imageList.length * Math.random())];
img.src = newImage;
};
// -->
</script>
</head>
<body>
<img id="main_img" src="blank.png" alt="The main image">
</body>
</html>
quote:I know. But I can do it in PHP without looking it up. Or as Jon Boy almost said, "I'd do it in PHP because I don't know JavaScript."
It's actually not so bad to do this in javascript rather than php. Here's an example: