why do i get bumped out of my code?

admin

Administrator
Staff member
I've been working with image swapping, and while my code works correctly the first time, on the second run, it terminates abruptly before swapping the actual image (which I verified using alert messages). I call my code from an onClick via an image within the page itself. Could someone please take a look and tell me what I'm doing wrong? It's driving me nuts! :eek:

function showNewPic(p){
//load selected Array if not already loaded
if(currentpic == 0){
var images = new Array(pickArray.length-1);
for (var i=0; i<(pickArray.length); i++) {
images = new Image();
images.src = "images/portfolio/" + pickArray + ".gif";}
}

if(currentpic + p > pickArray.length-1){
currentpic = 0; }
else if(currentpic + p < 0){ currentpic = pickArray.length;}
else{currentpic = currentpic + p;}

document.pfolio.src = images[currentpic].src;
}
</script>
 
Back
Top