0
Let’s say, I click the button More and I’m going forward to A - Z
.
Now I wish to go back to Z - A
click on the button Least.
Code:
var i = 0;
var j = 0;
var n = 0;
function prox(){
j++;
i += 20;
barra = texto.split("|");
document.getElementById('lista').innerHTML = ' ';
for ( x = n; x < i; x++ ){
if(barra[x]){
document.getElementById('lista').innerHTML += "<br>"+barra[x]+"<br>";
}
}
if (j) {n = i}
}
function ante(){
j--;
i -= 20;
barra = texto.split("|").reverse();
document.getElementById('lista').innerHTML = ' ';
for ( p = n; p > i; p-- ){
if(barra[p]){
document.getElementById('lista').innerHTML += "<br>"+barra[p]+"<br>";
}
}
if (j) {n = i}
}
texto =
// clique 1 - listagem 1
"|A|"+
"|B|"+
"|C|"+
"|D|"+
"|E|"+
// clique 2 - listagem 2
"|F|"+
"|G|"+
"|H|"+
"|I|"+
"|J|"+
// clique 3 - listagem 3
"|K|"+
"|L|"+
"|M|"+
"|N|"+
"|O|"+
// clique 4 - listagem 4
"|P|"+
"|Q|"+
"|R|"+
"|S|"+
"|T|"+
// clique 5 - listagem 5
"|U|"+
"|V|"+
"|W|"+
"|X|"+
"|Y|"+
"|Z|";
<div id="lista"></div>
<hr color=silver size=1>
<a onclick="ante();">« Menos</a>
|
<a onclick="prox();">Mais »</a>
Only, this one button less is not responding in the right way!
I think can do exactly as did the function
prox()
. All the same exceptbarra = texto.split("|").reverse();
, this is to keep– Miguel