I have a text box that I want to display a different message depending on the day of the week. I know I need to create a collection with the 7 items but I’m not sure where to go from there, my knowledge of code is relatively limited. Can anyone point me in the right direction?
There are numerous ways of implementing what you are after. Here is a simple take, assuming your display message is plain text and constant:-
const daysMessage = [ “Sunday tomorrow is Monday Yay” ,
“Monday Blues” ,
“Tuesday Message” ,
“Wed Message” ,
“Thursday thirsty” ,
“Friday TGIF” ,
“Saturday message” ]
$w.onReady( function () {
var d = new Date();
var n = d.getDay();
$w( “#textbox” ).value = daysMessage[n];
});
Thanks for your reply!
So where you’ve put “Sunday tomorrow is Monday Yay” I put my own message there? So I would replace it with “You know it’s the weekend, right?” and do that for the rest of the as well with my other messages?
yup, that’s right
Thank you so much! Only thing I had to change to make it work was $w( " #textbox " ).value to $w( " #textbox " ).text
Cheers