Variable text dependant on day of month

  Charlie Babbage 20:48 21 Jan 2007

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 2007

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 2007

... 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 2007

try it in ajax:
click here

  Charlie Babbage 09:52 06 Feb 2007

... 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.

Elsewhere on IDG sites

WPA2 hack: How secure is your Wi-Fi?

Add Depth Of Field to a photo using Tilt Shift Blur in Photoshop

iPhone tips & tricks

Comment afficher des fichiers cachés sur Mac ?