I am building a website for a friend, and she has asked me to make an image rotator on the home page, basically there will be a folder of images on the server and she wants the images to rotate on the home page. I have experience with XHTML, CSS, PHP & MySql hence why she has asked me, but Javascript is something I have always wanted to get into but never got around to, although I do have experience with C++ so the syntax is familiar to me. I have googled a number of solutions and cannot understand them, and I don't want to use code I don't understand. So... would someone be so kind as to help me with this...
so far I have:
function swap_img() { /*Here I create an array to hold image paths*/ var imgs = new Array("/images/rotating_images/meg.jpg","/images/rotating_images/student.jpg"); /*An infinite loop so that images continue to swap?*/ while(1) { /*This was just temporary to test it*/ var time = new Date(); /*As was this*/ if(time.getSeconds() == 10 || time.getSeconds() == 30 || time.getSeconds() == 60) { document.getElementById("home_img").style.backgroundImage = imgs[Math.floor(Math.random()*imgs.length)]; } } }
Also javascript doesnt appear to be working on the home page, I have tried just document.write and some text and nothing shows?
Any help is greatly appreciated
This post has been edited by 4D1: 05 December 2010 - 05:59 AM