Hi,
New User here, I want to create a feature for users where they can click a button (or maybe a time picker) and a timer appears next to it that counts down from 60 minutes to 0. I thought maybe I could use the Time Picker and Step code to do this, but i’m not exactly sure what that would look like.
See these examples for ideas:
These all seem to have a “date” in mind though. I just need it to countdown to zero.
They’re merely using date as the target for the countdown. If you prefer a more simple countdown, look at the Redirect Delay example. You of course don’t need to redirect. You can do whatever it is you want at the end of the countdown.
Thank you for the help, Im stuck on this last bit… I cant seem to make it stop at 0 it will say “nan” in the fields once it hits zero
export function button9_click(event) {
//Add your code for this event here:
$w("#button9").label = "Mage spawning in:";
let countSecondDown = 10;
let countHourDown = 1;
$w(“#text35”).text = “” + countSecondDown;
$w(“#text33”).text = “” + countHourDown;
let countdown = setInterval( function () {
countSecondDown–;
$w(“#text35”).text = “” + countSecondDown;
if (
countHourDown && countSecondDown === 0) {
countSecondDown = 10;
$w(“#text35”).text = “” + countSecondDown;
countHourDown–;
$w(“#text33”).text = “” + countHourDown;
} else if (countHourDown === 0){
$w(“#button9”).label = “Mage Has Spawned”;
countSecondDown = “–”
countHourDown = “–”
}
}, 1000);
}