Use the function setInterval() javascript:
var contador = document.getElementById('contador');
var TOTAL_CLIENTES = 10;
var intervalo = setInterval(function() {
contador.innerHTML = parseInt(contador.innerHTML, 10) + 1;
if (contador.innerHTML == TOTAL_CLIENTES) {
clearInterval(intervalo);
}
}, 500);
<p>Clientes cadastrados: <span id="contador">0</span></p>
The above code will increment the value of <span>
1 every 500 milliseconds. You can change the increment interval however you want, make it faster or slower.
TOTAL_CLIENTES
is your value coming from PHP:
var TOTAL_CLIENTES = <?php echo $admcadastros; ?>;
That is, you want the user of your site to see the client counter being incremented: "Registered customers: 0", "Registered customers: 1", [...] "Registered customers: TOTAL"? type, the counter is incremented by 1 every X seconds?
– tayllan
@tayllan that’s right! Correct
– Gladison Neuza Perosini
Maybe you wanted to take a look at
Easing Functions
, is the same principle of Fade-In and Fade-Out functions that you want to do, but in the case, instead of affecting the opacity of an image, you want it to be Total Clients multiplied by the function value. http://easings.net/pt– DH.
You have a functional demonstration right here at Sopt: http://answall.com/questions/102170/como-usar-unidade-de-tempo-menor-que-milissegundos-em-um-setinterval-ou-settimeo/102175#102175
– Bacco