/    Sign up×
Community /Pin to ProfileBookmark

Rotating Images

Can anyone please help me with this javascript code.. I had a person design it and the problem is that I have to add in the images names when I want to add them into the image rotation. Isn’t there a way to say rotate all images in this folder? Instead of image name, image name, etc.??? I would appreciate greatly any help on this.. Below is the persons rotating script that was made for me. I’m really new to this javascript stuff, so please go easy on me.

//<script language=”JavaScript”>
function LoadImg() {
var n=0;
var a=null;
var imgs = new Array();
/* enter list of image locations below */
var locs = [“img/r_img/img001”, “img/r_img/img002”, “img/r_img/img003”, “img/r_img/img004”, “img/r_img/img005”, “img/r_img/img006”, “img/r_img/img007”, “img/r_img/img008”, “img/r_img/img009”, “img/r_img/img010”];

n = locs.length;
n = Math.floor(Math.random() * n);
document.img1.src=locs[n] + “_01.jpg”;

//document.img2.src=locs[n] + “_02.jpg”;
}

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@Dan_DrillichFeb 16.2003 — You can accomplish this by having a server side script, which will generate the JavaScript locs array.

Cheers,

Dan
Copy linkTweet thisAlerts:
@jdaviaFeb 16.2003 — [i]Originally posted by kpowning [/i]

[B]Can anyone please help me with this javascript code..

I'm really new to this javascript stuff, so please go easy on me.[/B]
[/QUOTE]

In this portion of you code, you can either change these images names to yours. Or rename your image names to these. They are in [color=blue]blue[/color]
<i>
</i>["img/r_img/[color=blue]img001[/color]",
"img/r_img/[color=blue]img002[/color]",
"img/r_img/[color=blue]img003[/color]",
"img/r_img/[color=blue]img004[/color]",
"img/r_img/[color=blue]img005[/color]",
"img/r_img/[color=blue]img006[/color]",
"img/r_img/[color=blue]img007[/color]",
"img/r_img/[color=blue]img008[/color]",
"img/r_img/[color=blue]img009[/color]",
"img/r_img/[color=blue]img010[/color]"];

You can add more images,

"img/r_img/[color=blue]img011[/color]", Don't forget to keep this[color=blue] "]; [/color]at the end. Look at your code.
Copy linkTweet thisAlerts:
@kpowningauthorFeb 16.2003 — I understand that I can continue on with this script, but is there a way for javascript to rotate all images in a folder, without continuing this way: img/img_r/img1.001.jgp etc....

You you just have a script that says rotate everything in this folder???? Does that make any sense

PLEASE, ANY HELP WOULD BE GREAT.....What did you mean about a server-side script? Like I said, I'm really new with this stuff, what would that script look like?
Copy linkTweet thisAlerts:
@kpowningauthorFeb 16.2003 — Can anyone please help me on this or suggest anything????
Copy linkTweet thisAlerts:
@jdaviaFeb 16.2003 — As far as I know there is no way that images will be run in any way at all, unless you first add the image names to a script of some sort.

I am only asking --- I'm cool! --- Is it too much work or time to add them?

There is anothewr way for them to show one after the other, (or page after the other). By use of the META TAG. But that might be more work.
Copy linkTweet thisAlerts:
@kpowningauthorFeb 16.2003 — I think it could get too be too much work, because the images that will be rotating, are growing very fast in the folder. I was hoping that there was a code that would just look at a folder and say start with 1 and go to "". But I guess that isn't an option at this time... Thanks though for your help..
×

Success!

Help @kpowning 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.9,
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,
)...