Hello all,
Just took a JavaScript class, where they didn't teach us anything about slide shows. Now I have a client and I promised them a slide show on their website. I made an external Js file, and Firefox debugger keeps on giving me this error: document[place].src is undefined.
Here's the code from the external .js, again really unfamiliar with this so I based it off example code I found:
var num=0;
var imgName="pictures/";
var slideImg= new Array();
slideImg[0]=new imageItem(imgName+"1.jpg");
slideImg[1]=new imageItem(imgName+"2.jpg");
slideImg[2]=new imageItem(imgName+"3.jpg");
function imageItem(image_location)
{
this.image_item = new Image();
this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj)
{
return(imageObj.image_item.src)
}
function getNextImage()
{
if(num < slideImg.length)
{
var new_img=get_ImageItemLocation(slideImg[num]);
return(new_img);
}
else
{
num=1;
}
}
function switchImage(place)
{
var new_img = getNextImage();
document[place].src=new_img;
setTimeOut(switchImage(place));
}
The problem should be in the last function switchImage(). Any help at all would be appreciated guys, thanks!