Message that updates on its own

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
everyday?
-Thanks
 
Steve said:
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
everyday?

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.")
//-->
</script>
 
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?
 
Steve said:
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?

Yes, what Patty wrote is just a coumter.

My thoughts are:
Find the current day, then
1. Load a file according to that day
OR
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.
 
Steve said:
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?


P@tty Ayers said:
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.")
//-->
</script>

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