zubora
12-28-2002, 07:20 AM
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[i] = new Image();
images[i].src = "images/portfolio/" + pickArray[i] + ".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>
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[i] = new Image();
images[i].src = "images/portfolio/" + pickArray[i] + ".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>