While developing a Web site for a client, I encountered a problem with server-side includes (SSI) and the site host. My client wanted the pictures of her sample products on the home page to change each time a visitor accessed the page.
The result is this short script that chooses one of the images to show on a random basis each time the page is loaded. Here is the script:
<SCRIPT LANGUAGE="VBScript"> <!-- Sub Window_OnLoad Dim arrPic, intPic Randomize intPic = Fix(Rnd * 7) arrPic = Array("mink22", "minklamb", "rabbit24", "rabbit16", "mink2215", "lambeaver", "cameralrabbit23") Show.src = "bears/" & arrPic(intPic) & ".jpg" End Sub --> </SCRIPT>
And then in the body of the page, I placed the following code:
<A HREF="samples.html"> <IMG NAME="Show" border=0 alt="Don't you want one?"> </A>
This script could easily be adapted for more than just images. Because I had seven images, I considered using the Weekday function to change the image on a daily basis. This would have looked like:
<SCRIPT LANGUAGE="VBScript"> <!-- Sub Window_OnLoad Dim arrPic, intPic intPic = Weekday(1) arrPic = Array("mink22", "minklamb", "rabbit24", "rabbit16", "mink2215", "lambeaver", "cameralrabbit23") Show.src = "bears/" & arrPic(intPic) & ".jpg" End Sub --> </SCRIPT>