472,800 Members | 3,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,800 software developers and data experts.

Rotating random images from a directory.

I have seen many Javascripts that rotate images with each load or
refresh of the page but so far all I've found require hard coding the
image filename into the script. Does anyone know of a script that
pulls images randomly from a directory? Thus I would need only add
(or delete) images from that directory and they would display on the
web page respectively. All the images are the same size (90x90) but
there are hundreds so hard coding a script is not an interesting
solution. :)

Would caching be an issue for something like this and the same picture
would keep appearing rather than a new random selection?

By "rotating" I'm referring to with each loading or refresh of the
page, not the animated-like rotating whereby the picture changes every
nn number of seconds or such. I'm just looking to display a different
picture each time the page is loaded, no more than that.

TIA
Jul 23 '05 #1
1 3140


Sandy Bremmer wrote:
I have seen many Javascripts that rotate images with each load or
refresh of the page but so far all I've found require hard coding the
image filename into the script. Does anyone know of a script that
pulls images randomly from a directory? Thus I would need only add
(or delete) images from that directory and they would display on the
web page respectively. All the images are the same size (90x90) but
there are hundreds so hard coding a script is not an interesting
solution. :)


It is certainly easy to write some server side JavaScript or any other
server side script to randomly select a file name from a directory and
output the appropriate <img> element in a dynamically generated HTML page.
A client-side scripting approach doesn't make much sense for that.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: kingofkolt | last post by:
I have a directory of images, called "random". In it are the following files: 1.gif 2.gif 3.gif 4.gif I use this script to choose a random image and display it:
4
by: Ian Hubling | last post by:
I'm trying to complete a rotating banner ad within a page I have. The rotating add has four images that rotate in three-second increments. I've got the images to rotate ok - but now I want to go...
1
by: Grunt | last post by:
Hi, I have been trying to put together a rotating banner. the code works but I am having a problem with the caching of the banner images. no matter what I try the page is constantly reloading the...
31
by: Royal Denning | last post by:
I am designing a table with 2 columns and 20 rows. I want to insert small images (each with a link) and a text title in each cell of the table. On refresh of the page, I would like to have the...
10
by: Sehboo | last post by:
Hi, I am looking for code which can rotate pictures without refreshing the page. I want to read randomly selected 5 images from database and then keep on rotating them every 5 seconds. ...
3
by: Simon | last post by:
This problem has been driving me mad for months.... Seen a few posts on forums about it but no answers... No mention on MSDN etc. XP Pro SP1, VS.NET (c#) .Net framework 1.1, IIS 5.1. In a...
2
by: sgMuser | last post by:
Hi, I am not a good developer of Javascript codes. Needs this help to make some modification to this famous free javascript from Anarchos. i am using this in one of my webpage. What it does is,...
1
by: Sunshine192 | last post by:
Hi, I'm still kinda new to PHP so I could do with some advice. I'm using the code below to select and show a random image from a folder of images. rotate.php <?php // Make this the relative...
11
by: bdbeames | last post by:
What I have is a is two sets of images,(Weather, optical) there is about 30 images of is each set. I have script that will rotate through the images on the main page. The user is able to view...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.