sulay
December 27, 2019, 2:39am
1
I am trying to replicate a similar function; creating a form where one field can display the current month, another field displays last month, and a third field that displays 2 months back and so on.
Here’s a link to another site that I found with a working script, that has it updated every month automatically: https://chromecapitalfunding.com/merchant-qualifier/
Can anyone please assist. TIA!
1 Like
J.D
December 27, 2019, 12:22pm
2
You can do something like:
let months = ["January", "February", "March" , "April", "May", "June", "July", "August", "September", "October", "November", "December"];
let currentMonth = new Date().getMonth();
let monthsB = months.splice((currentMonth + 1) % 12).reverse();
months = months.reverse();
months.push(monthsB);
months = months.flat();
$w.onReady(() => {
$w(#currentMonthTextId).text = months[0];
$w(#MonthMinus1TextId).text = months[1];
$w(#MonthMinus2TextId).text = months[2];
//etc...
})
[forgot the mode12. Fixed)