/    Sign up×
Community /Pin to ProfileBookmark

Help w/Rotating Images Using JavaScript

Rookie question. Tx for any help you can give.

Downloaded the Javascript for rotating images today (part of it copied below).

Bottom line: I can’t get my images to rotate and I know it’s a stupid error with a simple fix, but I’m scratching my head. I’ve successfully placed the script on my blog, and the demo slideshow is working ([url]http://katebarbour.blogspot.com/)[/url].

I’ve tried uploading my own images, but with no success. When they do appear, they are static (and vertically stacked,oddly), rather than rotating.

Where do I place my images within the coding so they rotate and cycle through?

var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem(“http://javascript.internet.com/img/image-cycler/01.jpg“);
image_list[image_index++] = new imageItem(“http://javascript.internet.com/img/image-cycler/02.jpg“);
image_list[image_index++] = new imageItem(“http://javascript.internet.com/img/image-cycler/03.jpg“);
image_list[image_index++] = new imageItem(“http://javascript.internet.com/img/image-cycler/04.jpg“);
var number_of_image = image_list.length;
function imageItem(image_location) {
this.image_item = new Image();
this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) {
return(imageObj.image_item.src)
}
function generate(x, y) {
var range = y – x + 1;
return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
if (random_display) {
image_index = generate(0, number_of_image-1);
}
else {
image_index = (image_index+1) % number_of_image;
}
var new_image = get_ImageItemLocation(image_list[image_index]);
return(new_image);
}
function rotateImage(place) {
var new_image = getNextImage();
document[place].src = new_image;
var recur_call = “rotateImage(‘”+place+”‘)”;
setTimeout(recur_call, interval);
}
// End –>
</script>

<center>
<img name=”rImage” src=”http://javascript.internet.com/img/image-cycler/01.jpg” width=120 height=90>
</center>

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@FangSep 20.2007 — All you need to do is change the image names and path in image_list.
Copy linkTweet thisAlerts:
@girl_fridayauthorSep 20.2007 — Thanks Fang.

I know how to change the images, but I don't know how to modify the path. I see where it is, but I don't know what to replace it with.

(New Star Trek fan only or do you like the old stuff too?)
Copy linkTweet thisAlerts:
@FangSep 21.2007 — Give the path to images and document from the root.

(not keen on Kirk episodes)
Copy linkTweet thisAlerts:
@girl_fridayauthorSep 25.2007 — That isn't working.

There must be something else I need to modify.

(Too bad. Those are my favorites. Mom raised us on them. We owned a bunch of episodes on VHS and the rest we caught as reruns. But I'm a Next Generation fan, too. Too bad I can't find re-runs of those anywhere.)
Copy linkTweet thisAlerts:
@girl_fridayauthorSep 25.2007 — Does this need changed somehow?

<center>

<img name="rImage" src="http://javascript.internet.com/img/image-cycler/01.jpg" width=120 height=90>

</center>
Copy linkTweet thisAlerts:
@FangSep 25.2007 — These must be changedmage_list[image_index++] = new imageItem("[COLOR="Red"]http://javascript.internet.com/img/image-cycler/01.jpg[/COLOR]");

and this&lt;img name="rImage" src="[COLOR="Red"]http://javascript.internet.com/img/image-cycler/01.jpg[/COLOR]" width=[COLOR="Red"]120[/COLOR] height=[COLOR="Red"]90[/COLOR]&gt;
to your own path and images.
×

Success!

Help @girl_friday spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...