APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

JavaScript Calendar

© December 1997 Tony Lawrence

This is a Javascript calendar program. If you don't have Javascript enabled, or if your browser doesn't support Javascript, you won't see anything but this message. It's not terribly difficult to extend this so that it becomes a web based scheduler, an in-out board, or anything else.

Javascript is not Java. Javascript is a scripting language developed by Netscape, and really has nothing to do with Java. Javascript isn't cgi-bin programming, either. The script is actually in the HTML page. You can't see it if you "View Source"; all you'd see is the HTML tags and text that the Javascript program produced. Here you can see what is really going on.

<script language="JavaScript" type="text/javascript">
<!-- yes this should look like this

function calendar() {
var now=today.getDate();
var tmonth=today.getMonth();
var tyear=today.getYear();
if (tyear < 1000) {tyear += 1900};
var d=new Date(year,month,"1");
var dd=new Date(year,nextmonth,"1");
var aday=(1000 * 60 * 60 * 24);
var ms=dd.getTime();
ms -= aday;
var lastday=dd.getDate();

var sd=d.getDay();

if (pmonth < 0) { pmonth=11; pyear--;}
if (nmonth > 11) {nmonth=0; nyear++;}
document.write("<h2>Calendar for  ");
document.write(names[month] + " " + year);

document.write("<TABLE BORDER width=\"50%\" cellwidth=\"14%\" CELLpadding=8>");
var y=1;
for ( x=0; x < sd ; x++) {
for ( x=sd; x < lastday + sd; x++) {
document.write("<TD width=\"100\" >" +   $bstart + y + $bend  + "<\/td>");
if ((t % 7) == 0) { document.write("<\/TR><tr>")}; 
if (y == now && tmonth==month && tyear == year) { $bstart="<b><font color=\"blue\"> ";$bend="<\/font><\/b>"; } else
{ $bstart="";$bend="";}
var today=new Date();

var month=today.getMonth();
var nextmonth=month+1;
var year=today.getYear();
if (year < 1000) {year += 1900};
if (nextmonth > 12) {nextmonth=1};month;

names=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var x=0;

// and this should look like this -->

Got something to add? Send me email.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> Javascript CalendarProgram

Inexpensive and informative Apple related e-books:

Take Control of High Sierra

Photos for Mac: A Take Control Crash Course

Photos: A Take Control Crash Course

Take Control of Pages

Take Control of Automating Your Mac

More Articles by © Tony Lawrence

Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Printer Friendly Version

The errors which arise from the absence of facts are far more numerous and more durable than those which result from unsound reasoning respecting true data. (Charles Babbage)

Linux posts

Troubleshooting posts

This post tagged:



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode

SCO Unix Sales, Support, & Service

Phone:  707-SCO-UNIX (707-726-8649Toll Free: 833-SCO-UNIX (833-726-8649)