Click to See Complete Forum and Search --> : Java Script Image Cycler
Hello, to all
Iam very new in Java Script, Iam trying to use the image cycler,but it seems that is not working.
Is there something very important that i had to change in the given script, and I didn't?
Please give me some help.
Thank you very much
AdamGundry
10-04-2003, 02:48 PM
We can't help without seeing the script you are using. Please post the code and a more accurate description of the problem than "not working".
Adam
the code that Iam using is given from this site, is:
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<! >
<! >
<!-- Begin
var timeDelay = 20; // change delay time in seconds
var Pix = new Array
("01.jpg"
,"02.jpg"
,"03.jpg"
,"04.jpg"
);
var howMany = Pix.length;
timeDelay *= 1000;
var PicCurrentNum = 0;
var PicCurrent = new Image();
PicCurrent.src = Pix[PicCurrentNum];
function startPix() {
setInterval("slideshow()", timeDelay);
}
function slideshow() {
PicCurrentNum++;
if (PicCurrentNum == howMany) {
PicCurrentNum = 0;
}
PicCurrent.src = Pix[PicCurrentNum];
document["ChangingPix"].src = PicCurrent.src;
}
// End -->
</script>
</HEAD>
BODY OnLoad="startPix()">
<img name="ChangingPix" src="01.jpg">
The problem that although I have put four diffrent images in the same directory, the images are not cycling. I can see only the 01 "static". Is there something that I have to change? Iam using Dremweaver, and IE
Thank you very much for your help.
AdamGundry
10-05-2003, 01:57 AM
Here's a slightly cleaner version, which assumes you have images "01.jpg" to "04.jpg" in the same directory - untested, but it should work.
<script type="text/javascript">
// change delay time in seconds
var timeDelay = 20;
// change picture file names
var Pix = new Array
("01.jpg"
,"02.jpg"
,"03.jpg"
,"04.jpg"
);
// do not change below here
timeDelay *= 1000;
var PicCurrentNum = 0;
function startPix() {
setInterval("slideshow()", timeDelay);
}
function slideshow() {
PicCurrentNum++;
if (PicCurrentNum == Pix.length) {
PicCurrentNum = 0;
}
document.getElementById('ChangingPix').src = Pix[PicCurrentNum];
}
</script>
</head>
<body onload="startPix()">
<img id="ChangingPix" src="01.jpg">
Adam
Adam thank you very very much.
IT WORKS!!
Thanks a lot
Have a nice day.
AdamGundry
10-05-2003, 02:05 PM
No problem. :)
Adam