Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 312 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making a number change gradually rather than immediately

#1
I would like to change a number from n1 to n2 gradually that is if n1 is 5 & n2 is 10 then I want it to change like 6, 7, 8, 9, 10 instead of changing abruptly from 5 to 10

Here is the part;

var interval = setInterval(gMoneyU1, 1000);
function gMoneyU1()
{
var calc = 5 * U1Amount;
Money += calc;
document.getElementById('money').innerHTML=Money + "$";
}

Reply

#2
Here you have:

var interval = setInterval(gMoneyU1, 1000);
var Money = 0, U1Amount = 1; //Start U1Amount in 1
function gMoneyU1()
{
var calc = 5 * U1Amount;
Money += calc;
U1Amount++; //Increment amount by 1
document.getElementById('money').innerHTML=Money + "$";
}

Cheers
Reply

#3
I think you should use setTimeout to achieve this, I am writing a more general code but you can easily fit it to your case


var initial = 0;
var final = 5;

function change(current, expected){
if(current != expected){
setTimeout(function(){
current += ((expected-current > 0) ? 1 : -1)); //increment or decrement based on the case
change(current, expected);
}, 1000);
}
}

change(0, 5);
Reply

#4
Here is my understanding of this question :

var money = 5,
ceiling = 10,
el = document.getElementById('money'),
tid = setInterval(update, 500);

function update() {
refresh(++money);
if (money === ceiling) clearInterval(tid);
}

function refresh(value) {
el.innerHTML = value + '$';
}

refresh(money);

Have a look at the demo :

[To see links please register here]

.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through