JS: image swap on page load

I have a folder full of images (with specific quotes in them) that I would like to randomly swap out on page load.  Not sure the best way to get this done.
a204801Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ares KurkluSoftware EngineerCommented:
If the images can have the same name like pic001, pic002 then you can simply generate a random number let's say if you got 100 images , you can generate a number between 1 to 100 and load that image, another way would be somehow to keep a database of the file names or can be hardcoded  array (not ideal)
or read all the image names in the folder order them by name in an array, get the max number of images then randomly pick a number and display that. first option may be the simplest one.

You can do it in JS or in jQuery and display onload.
0
a204801Author Commented:
The images are in its own folder and are labeled 001.png, 002.png and so on.  I dont know how to write the code.  How might you conceive it?
0
Ares KurkluSoftware EngineerCommented:
There are some good examples in the following links you may follow those:

http://www.dyn-web.com/code/random-image-js/

http://www.mediacollege.com/internet/javascript/image/random.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
a204801Author Commented:
perfect.  thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.