Variable text dependant on day of month

  Charlie Babbage 20:48 21 Jan 07

I want to include some short text in a web page which would vary according to the current day of the month.

What is the easiest way of doing this, particularly as the server click here does not support anything sophisicated like php scripts?!

I realise that I would probably have to set up the text in a table and then lookup that table having found the current day of the month.

Any assistance given would be much appreciated with relevant code!

  RicScott 11:03 22 Jan 07

datetoday = new Date();
thehour = datetoday.getHours();
if (thehour > 18) display = "Evening";
else if (thehour >12) display = "Afternoon";
else display = "Morning";
var greeting = ("Good " + display + "!");
// -->

This will put a Good Morning, Good Afternoon etc depending on the time of the day...
You can of course swap the good morning etc messages for something else...

  Charlie Babbage 22:59 22 Jan 07

... why does the following only display the text for the 1st day of the month whereas today is the 22nd day at the time of writing? When I first wrote this code I did not start with 'if (daynow=1) but with '(daynow=22) and it worked fine. What I want displayed is a different text depending on the day of the month.

datetoday= new Date()
if (daynow=1) prayer="Please pray for the Churchwardens, Charlie Jones and Michael Swinson. Sidespeople. Also for people in these
residential homes: Kelton Grange, Geel.";
else if (daynow=22) prayer="Please pray for Mission Link: Mark, Shirley, Lisa and Martin Sinclair (OMF) in Phnom Penh, Cambodia and
for homes in these roads: Templemore, Avonmore, Purley Grove, Boxmore Road";
else if (daynow=23) prayer="Please pray for the Local Police, Fire service, Social Serrvices and Businesses in the area. Also for homes in these roads: Kirkmore, Rexmore, Benmore, Cairnmore and
else if (daynow=24) prayer="Please pray for newly baptised children/adults and their families and the Baptism preparation team. Also for homes in these roads: Erylmore, Lismore, Incemore, Lochmore and Craigmore";
// -->

Any further assistance would be much appreciated.

  RicScott 21:50 05 Feb 07

try it in ajax:
click here

  Charlie Babbage 09:52 06 Feb 07

... I have not come across ajax before and shall be interested to look at it. I've also borrowed a book on Javascript from the library!

This thread is now locked and can not be replied to.

Nintendo Switch review: Hands-on with the intuitive modular console and its disappointing games…

1995-2015: How technology has changed the world in 20 years

This abstract video touches on division in our technologic world

Best alternatives to iTunes for Mac | Best music players for macOS: Free your music from the…