javascript to display text based on a date?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi, I am a college online teacher, I know enough javascript to be
dangerous, pretty good at basic HTML. I could use some help on what I
think is a simple problem:  I need to be able to have my HTML web page
display text in a paragraph or cell of a table only after a certain
date.  Is there a simple way to do this with javascript?

Basically I have my online course entry page with topics listed in a
table-- left column calendar date ranges, right column descriptions of
the topics with links to the page for each topic.  I do not want
students to get ahead of themselves, so I would like to be able to
pre-program the webpage with javascript to only display a link for a
topic after a specified calendar date.

Any help greatly appreciated, thank you.

Re: javascript to display text based on a date?

Beowulf wrote:
Quoted text here. Click to load it

The problem with Javascript is, it works client-side.....So if someone wants
to vew the text before the due date, all they have to do is alter their
system clock.....I'd personally go with a client-side solution using ASP if
this were my project.....

Having said that.....

<script type="javascript">
var triggerDate=new Date()
var today = new Date()
if (today=>triggerDate)
document.write('The text from your inserted paragraph goes here')

This should display the paragraph text if the current date is equal to, or
later than September 1st 2006.

Note that the days of the month are counted starting from 1, but the months
of the year are counted starting from 0....

Re: javascript to display text based on a date?

Beowulf wrote:
Quoted text here. Click to load it

Even if it didn't display in the browser window, with Javascript it
would still display in the source.  Javascript is client-side, so all
the data would be sent and Javascript would decide whether to display it
or not.  But displaying the page source will always show it.

You need a server-side language such as PHP, Perl, VBScript, etc.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Site Timeline