Message that updates on its own

Message that updates on its own

Post by U3Rldm » Wed, 18 Oct 2006 04:21:01

I am currently building a site for a company that holds various events day to
day. I want to add a message (preferably scrolling) that updates itself. The
message on the site would read something like this: "we are having a meeting
on tuesday at so and so" the next day the text would read: "we will be
meeting on friday at blah blah"
Instead of having to update the page everyday I was wondering if this is
possible. I will know the events that are happening a week or two in advance.
Is there a way I could plug the messages into a code which then updates

Message that updates on its own

Post by » Wed, 18 Oct 2006 06:22:48

Why preferably scrolling? Scrolling messages are hard to read; you usually
only see them on old or amateur sites, if you notice - just a thought.

You can do it, with JavaScript. Here's code I've used. This example tells
you how many days until St. Patrick's Day, but obviously you could change
the date and the text that displays.

Put in body of page where statement needs to go:

<script language="JavaScript">
var now= new Date();
var stpats = new Date("March 17, 2007" );
var how_long= stpats.getTime() - now.getTime();
var days = Math.ceil(how_long/ (60*60*1000*24));
var from= (how_long<0)? "since":"until"
document.write("There are "+days+" days "+from+" St. Patrick's day.")

Patty Ayers |
Free Articles on the Business of Web Development
Web Design Contract, Estimate Request Form, Estimate Worksheet


Message that updates on its own

Post by U3Rldm » Wed, 18 Oct 2006 07:51:02

Good point to the scrolling text. The code is cool and I think I may use it,
im just not sure how too! The text needs to be different almost every day. It
seems that that code is just a counter. Any help?

Message that updates on its own

Post by Trevor L » Wed, 18 Oct 2006 15:27:06

Yes, what Patty wrote is just a coumter.

My thoughts are:
Find the current day, then
1. Load a file according to that day
2. Look up an array of messages and display the one for that day

Another possibility is to have a database of messages and retrieve one of
these according to the day, but that may be getting too complicated.

I think option 2. above would work quite well.

You would have an array such as:
var message = new Array(
"20061017" , "message for 17 October 2006" ,
"20061018" , "message for 18 October 2006" ,
"20061019" , "message for 19 October 2006" ,
"20061020" , "message for 20 October 2006" ,
"20061021" , "message for 21 October 2006"

When the date is returned, say "20061018", the array is searched until this
value is found and the next element in the array is displayed.

With this set up, you can delete the old values and just keep adding new
ones at the end (provided you keep the format correct). But you can also
keep them all if you want.

If you are interested in this idea, I will try to write the code and post it
in a day or so.
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website:

Message that updates on its own

Post by Jeff » Wed, 18 Oct 2006 23:41:46

What I did, was make a table in a db that could be updated or inserted to.
Then have some script check the date, and update the scroll accordingly.
The new entries could be inserted by anyone who has that page with the form
on it, so some security might be in order as well.