Javascript Pic Slideshow Failing? -
for reason code not executing properly. trying program slideshow javascript. im using loop pull , populate src files created array , change pic every 3 seconds. page loads , first pic present when interval occurs first pic dissapears , nothing falls in place. doing wrong?
<img name="mainslide" id="mainslide" src="images/mainpagephotos/facebook-20131027-180258.png" alt=""> var mainslidepics = ("facebook-20131027-180258.png","img_9694116683469.jpg","img_28452769990897.jpg"); window.onload = setinterval("mainslide();", 3000); function mainslide() { for(i=0; i<mainslidepics.length; i++ ) { document.images.mainslide.src = "images/mainpagephotos/" + mainslidepics[i]; } }
have tried getting id first?
var mainslide = document.getelementbyid("mainslide"); mainslide.src = "images/mainpagephotos/" + mainslidepics[i];
also forloop loop finishes loops in 1 call. try
var = 0; window.onload = setinterval("mainslide(i);", 3000); mainslide(int j){ mainslide.src = "images/mainpagephotos/" + mainslidepics[i]; setinterval("mainslide(j++);", 3000); }
Comments
Post a Comment