rtareva
06-06-2008, 10:40 PM
Here is a simple slideshow http://www.rumenvasilev.com/photography/nature/index.php using <a href="#" onClick="prev();"> «</a> <a href="#" onClick="next();"> » </a>
Images load to the fourth one then stop. Can’t see what’s the problem I am sure it is silly. Any ideas?
Here is the code:
// Lists image names without extension var myImg= new Array(3)
myImg[0]= "01";
myImg[1]= "02";
myImg[2]= "03";
myImg[3]= "04";
myImg[4]= "05";
myImg[5]= "06";
myImg[6]= "07";
myImg[7]= "08";
myImg[8]= "09";
myImg[9]= "10";
// Tells browser where to find the imagemyImgSrc = "/photography/nature/";
// Tells browser the type of file myImgEnd = ".jpg"
var i = 0;
// Creates function to load image function loadImg(){
document.imgSrc.src = myImgSrc + myImg[i] + myImgEnd;
}
// Creates link function to switch image backward function prev(){
if(i<1){
var l = i
} else {
var l = i-=1;
}
document.imgSrc.src = myImgSrc + myImg[l] + myImgEnd;
}
// Creates link function to switch image forward function next(){
if(i>2){
var l = i
} else {
var l = i+=1;
}
document.imgSrc.src = myImgSrc + myImg[l] + myImgEnd;
}
// Loads function after page loads window.onload=loadImg;
TNX for your time
Images load to the fourth one then stop. Can’t see what’s the problem I am sure it is silly. Any ideas?
Here is the code:
// Lists image names without extension var myImg= new Array(3)
myImg[0]= "01";
myImg[1]= "02";
myImg[2]= "03";
myImg[3]= "04";
myImg[4]= "05";
myImg[5]= "06";
myImg[6]= "07";
myImg[7]= "08";
myImg[8]= "09";
myImg[9]= "10";
// Tells browser where to find the imagemyImgSrc = "/photography/nature/";
// Tells browser the type of file myImgEnd = ".jpg"
var i = 0;
// Creates function to load image function loadImg(){
document.imgSrc.src = myImgSrc + myImg[i] + myImgEnd;
}
// Creates link function to switch image backward function prev(){
if(i<1){
var l = i
} else {
var l = i-=1;
}
document.imgSrc.src = myImgSrc + myImg[l] + myImgEnd;
}
// Creates link function to switch image forward function next(){
if(i>2){
var l = i
} else {
var l = i+=1;
}
document.imgSrc.src = myImgSrc + myImg[l] + myImgEnd;
}
// Loads function after page loads window.onload=loadImg;
TNX for your time