I want to step through an array with a next and previous button. Each button calls the same function as it is in. I have the following code...
function displayPic(i) {
if (i == 0) {
$('#map_holder').empty();
$('#map_holder').append(picArray[i] + '<br><input id="next" type="button" value="Next" onclick="displayPic(' + i + 1 + ');" />');
if (i == picArray.length - 1) {
$('#map_holder').empty();
$('#map_holder').append(picArray[i] + '<br><input id="prev" type="button" value="Prev" onclick="displayPic(' + i - 1 + ');" />');
}
else {
$('#map_holder').empty();
$('#map_holder').append(picArray[i] + '<br><input id="prev" type="button" value="Prev" onclick="displayPic(' + i - 1 + ');" /> <input id="next" type="button" value="Next" onclick="displayPic(' + i + 1 + ');" />');
}
}
}
Any help?
onclick="displayPic(01)"andonclick="displayPic(12)". Can you guess what you'd have to change? Also,displayPicwon't do anything at all ifi > 0.