Does anyone know how to have an image change to a random image when the page loads and/or refreshes, and also have it where if you click on the image is goes to the next image, in sequence? Thanks!
lonrat
0
Newbie Poster
Recommended Answers
Jump to PostCan you be more specific? What are you trying to achieve? A slideshow? Or just displaying random images that can be cycled by clicking on them?
Jump to PostSo many possibilities. If you already have an array of image paths in Javascript in your page source (e.g. 'imagepaths'), here's a function to pick a random index to select the next image (different from the last).
function nextindex(previous) { // slidemax is the size of your …
Jump to PostHi,
Looking at your code, here's what I suggest.
NOTE THIS HAS NOT BEEN TESTED, maybe some work left for you to do.
I modified the randomize function to give access to the image array and image number. Then added an 'onclick' event to call a function which finds the …
All 11 Replies
PcPro12
3
Junior Poster
nauticalmac
11
Newbie Poster
JorgeM
958
Problem Solver
Team Colleague
Featured Poster
lonrat
0
Newbie Poster
nauticalmac
11
Newbie Poster
lonrat
0
Newbie Poster
nauticalmac
11
Newbie Poster
lonrat
0
Newbie Poster
nauticalmac
11
Newbie Poster
lonrat
0
Newbie Poster
nauticalmac
11
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.