Forum Moderators: open
However, in order for it to work for my site I need to be able to advance through an array. Any way to set it up so that the coordinates of a click are read in by a javascript function?
I'm not sure if I'm even phrasing this right. I have only a basic knowledge of programming but can grasp the concepts and understand what I'm reading pretty well.
advancePhoto = function(){
// Cycle through to end, then repeat
if(photoId == (photoArray.length - 1)){
photoId = 0;
} else {
photoId++;
}
return photoId;
}
advancePhoto();
Within javascript, I want to be able to call this function only if the user clicks on the right half of the photo. A similar function would get called if the other half were to be clicked.
// Set source, width, and height of new photo
document.getElementById('Photo').src = photoDir + photoArray[photoId];
document.getElementById('Photo').width = wNew;
document.getElementById('Photo').height = hNew;
document.getElementById('NextLink').href = "#" + (photoId+1);
document.getElementById('Caption').innerHTML = captionArray[photoId];
document.getElementById('Counter').innerHTML = (photoId+1)+' of '+photoNum;
How and where would I specify the image coordinates to call
document.getElementById('PrevLink').href = "#" + (photoId-1);
for the left half of the photo instead of the fifth line of code which is currently the only link?