Eivo Posted January 29, 2007 Share Posted January 29, 2007 I am starting a new site and I was wondering if there was a way for a site to cycle through or pick an image at random every time it loads. What I want to do is have my header image change anytime the page loads. Just something to get the clients excited about their site. Can this be done, and if so, how? Thanks in advance. Link to comment Share on other sites More sharing options...
Anders Moen Posted January 29, 2007 Share Posted January 29, 2007 You can use JavaScript or ASP or PHP.If you have an ASP host, you can use the AdRotator function in ASP (link). The other two I don't know, just what I'm looking for too :)Good luck further! Link to comment Share on other sites More sharing options...
Eivo Posted January 29, 2007 Author Share Posted January 29, 2007 You can use JavaScript or ASP or PHP.If you have an ASP host, you can use the AdRotator function in ASP (link). The other two I don't know, just what I'm looking for too :)Good luck further!Is that for ASP.NET or ASP (Classic)? Link to comment Share on other sites More sharing options...
Anders Moen Posted January 29, 2007 Share Posted January 29, 2007 Don't know. I'm not familiar with ASP yet.But I choose the URL www.w3schools.com/asp so I think it's the "normal" one. Link to comment Share on other sites More sharing options...
aquatsr Posted February 3, 2007 Share Posted February 3, 2007 I am starting a new site and I was wondering if there was a way for a site to cycle through or pick an image at random every time it loads. What I want to do is have my header image change anytime the page loads. Just something to get the clients excited about their site. Can this be done, and if so, how? Thanks in advance.PHP FTW ? heh. You can utilize PHP to 'randomly' select from a list of images. I did it for a background logo of a site I made a few years back. Link to comment Share on other sites More sharing options...
jlhaslip Posted February 3, 2007 Share Posted February 3, 2007 Simply place all of the possible banners in one folder, have the page read the filenames of all the banners in that folder into an array and randomize the selection of one of those banners from the array. Check the array functions at php.org/com/net, I forget where, exactly they hid all that php info... *wait* ...check at w3schools... !!!*edit*That would be http://www.php.net and try the array_rand() function. Link to comment Share on other sites More sharing options...
aquatsr Posted February 3, 2007 Share Posted February 3, 2007 Simply place all of the possible banners in one folder, have the page read the filenames of all the banners in that folder into an array and randomize the selection of one of those banners from the array. Check the array functions at php.org/com/net, I forget where, exactly they hid all that php info... *wait* ...check at w3schools... !!!*edit*That would be http://www.php.net and try the array_rand() function.Hmmm. That's right, it would work but it's making it more complicated than it needs to be. For beginners, arrays are sometimes difficult to comprehend.The way I did it was to use the rand() function to pull a number, then an if statement that showed a particular image for a particular number. It certainly isn't as efficient as an array, but it's easier to understand.Anyway it's like 3 or 4 am local time, so I'm out. Link to comment Share on other sites More sharing options...
Skemcin Posted February 4, 2007 Share Posted February 4, 2007 I share an easy to use Javascript snippet here:http://w3schools.invisionzone.com/index.php?showtopic=9500 Link to comment Share on other sites More sharing options...
Kevin M Posted February 4, 2007 Share Posted February 4, 2007 I made a baisc PHP one a little while ago. <?php$image[0] = '<img src="IMG LINK" alt="ALT TEXT" />';$image[1] = '<img src="IMG LINK" alt="ALT TEXT" />';$image[2] = '<img src="IMG LINK" alt="ALT TEXT" />'; $image[3] = '<img src="IMG LINK" alt="ALT TEXT" />'; echo $image[rand(0,3)]; ?> Then to add more, put another line into the array: $image[Number 1 Higher than the greatest number there] = '<img src="IMG LINK" alt="ALT TEXT" />';And change the bold number to the highest number in the array. echo $image[rand(0,3)]; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now