Adding a Calendar to Your Page

Many Web applications need a calendar that the user can refer to and interact with. Reservation forms, to-do lists, navigation for posts on weblogs—the list goes on and on. The YUI library has a good calendar widget that is easy to implement (Figure 14.3).

Figure 14.3. When you hover over a future date, the date highlights.

The simple HTML for our calendar appears in Script 14.4. The CSS is in Script 14.5, and Script 14.6 shows you how to add the JavaScript for an interactive, one-up calendar (where only one month appears).

To add a one-up calendar:

1.
<link type="text/css" rel="stylesheet" href="yui/calendar.css" ...

Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.