Click to See Complete Forum and Search --> : Rotating Images
kpowning
02-15-2003, 07:41 PM
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";
}
Dan Drillich
02-15-2003, 08:21 PM
You can accomplish this by having a server side script, which will generate the JavaScript locs array.
Cheers,
Dan
jdavia
02-15-2003, 08:32 PM
Originally posted by kpowning
Can anyone please help me with this javascript code..
I'm really new to this javascript stuff, so please go easy on me.
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 blue
["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"];
You can add more images,
"img/r_img/img011", Don't forget to keep this "]; at the end. Look at your code.
kpowning
02-15-2003, 09:03 PM
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?
kpowning
02-15-2003, 11:06 PM
Can anyone please help me on this or suggest anything????
jdavia
02-16-2003, 02:53 PM
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.
kpowning
02-16-2003, 03:07 PM
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..