The DHTML Calendar is a lightweight DHTML widget that can be used as a date selector. Currently it supports date ranges from 1582 AD to 5000 AD based on a Gregorian calendar. (Even though the Gregorian calendar didn’t exist that far back.)

DHTML Calendar contains some code from a calender script by Mihai Bazon. It contains many more features but is much larger in size.

Features

  • support Gregorian dates from 1582 AD to 5000 AD
  • small size, less than 15k
  • simple interface
  • holding down mouse over the year arrows causes it to jump in 10 year increments after ~.6 secs
  • supports a wide variety of browsers (Opera 7+, IE6, FF 1.x, Netscape 8, Mozilla 1.7)

Misc

To Do

  • keyboard support
  • Internationalization

Revision History

Release 0.3

  • ran js through a validator and fixed a couple of minor bugs
  • added z-index to css files

Release 0.2

  • fixed day of the week calculation
  • limited min year to 1582 (creation of gregorian calendar)

Release 0.1

  • alpha release

Calendar API

There are only two methods you should need for interfacing with the calendar.

Calendar.show(anchor, month, year, callback, tag)

The Calendar.show method creates and displays the calendar. Once displayed the calendar will close when a date is selected or the close button in the upper right corner is clicked. The method takes up to 5 arguments. They are described below.

anchor – There value past in is a javascript object reference. This determines where the calendar will be displayed. It is displayed at the bottom of the anchor on the left.

month – This is the month (January = 0) that the calendar will initially display. If an invalid value is provided, it will use the current month.

year – This is the year that the calendar will initially display. If an invalid value is provided, it will use the current year.

callback – This is the javascript function that will be called when a date has been successfully selected. It takes three arguments: month (January = 0), day, year. It DOES NOT get called when the window is closed with the close button.

tag – This is the prefix assigned to all classes and ids of the elements created to display the calendar. It is also the name used to identify the calendar in the cache.

Calendar.closeAll()

The calendar.closeAll method takes no arguments and provides away to close the displayed calendar outside the calendar itself. When the calendars are closed with this method, the callback function is not called.