I have an array of information I need to display in a function called updateMyInfo, which accepts an argument of the current index number. I start displaying the items at index 0, and there is a next/previous button to move through the array. So,I try:
// make the function visible anywhere
updateMyInfo = updateInfo;
function updateInfo(index) {
slide.$("title").html(mySlide[index].title);
slide.$("info").html(mySlide[index].info);
slide.$("img").attr("src", "images/" + mySlide[index].img);
}
var next = sym.getSymbol('details').getSymbolElement('next');
index = 0;
updateMyInfo(0);
next.click(function(){
index++;
updateMyInfo(index);
});
The function is called once with index=0, great. I click next, index is 1 and second data shows. I click next again and index is 0 again.