SOLVED - Repeating a piece of code

Hi,

So I have this piece of code which I wish to run 5 times:

$w("#repeater1").hide('slide', imout)
$w("#myDataset").next()
setTimeout(() => {
    $w("#repeater1").show('slide', waitin)
}, 1000)

I could enter it 5 times, but isn’t there a solution?
And also, I have a code which I wish to repeat forever. Is this possible?

Thanks, would really help!

try:

function myFunction(){
$w("#repeater1").hide('slide', imout);
$w("#myDataset").next();
setTimeout(() => {
    $w("#repeater1").show('slide', waitin);
}, 1000)
}
for(let i = 0;  i  <  5; i++) {myFunction();}

Or try duplicating the page 5 times.

The 5th page you duplicate will automatically run the code 5 times.

This is a new feature or bug (however you want to call it)

:slight_smile: . (But really Shan, some people might think you’re serious and not joking…)

FYI: I’m just kidding (or maybe not)

Its best you follow JD’s above given solution https://www.wix.com/corvid/forum/main/comment/5cea9dd01d1354015ac98c7b

Thanks!

Lol, no, I’m not that stupid.

Does anyone also know how I can loop/repeat something forever?

You can use the setInterval() method :

setInterval(() => {
	// Put the code you want to run	here 		
	}, 1000)//time in milliseconds. In this example every 1 second