Making an text number keep increasing

hello there… im trying to make an text number that will keep increasing by 0.01 using java.
but the code i used on my server somehow not work at wix here… can any one help with it?
below are the code i using:

setInterval(function () { 
	var $badge = $w("#Number"); 
	$badge.text = ((parseFloat($badge.text())+0.01).toFixed(2)); 
}, secs); 

the debug page showing : TypeError: $badge.text is not a function.

second i try with this code

setInterval(function () { 
	var $badge = $w("#Jackpot"); 
	$badge.text = ((parseFloat($badge.text=(10))+0.01).toFixed(2)); 
}, secs); 

it only give the result of 10+0.01 = 10.001…
it wont keep increasing like 10.002, 10.003

Hi,

In your first example, you are getting the error $badge.text is not a function because you are trying to call a function $badge.text() . In the second example, $badge.text , you used text as a property (by leaving out the parentheses) which is the correct way to access text .

This code should work for you:

setInterval(function () {
   var badge = $w("#text1");
   let val = Number(badge.text); // get text val and make it a number
   val = val + 0.01;
   $w("#text1").text = "" + parseFloat(val).toFixed(2);// make it text
}, 3000);     // 3 seconds is 3000 milliseconds

Good luck,

Yisrael

Greats and thanks for helping
can i know how to make the
val = val + 0.01;
this code to make it increase randomly between 0.01 to 1.00 each tick?

solved.
i just change the code to
val = val + (Math.random() * 1);

thx for the help

Great! Glad you got this working the way you want.

How to stop the setInterval function at some point in time (let’s say at 10)?

Hey I am also having the same doubt did you figure it out?
Can you please guide me.
and i also want to get the final no. as a WHOLE NO.

@bluezonegaurav Hi Gaurav, This thread is a couple of years old. Please create a new post with your question, including all relevant details, code, and screenshots. Here are our guidelines to help you write your new post. Thanks.