Javascript and Calendar Essay

Submitted By Cassidy-Anochie
Words: 860
Pages: 4

Popup Calendar for AcroForms
By Thom Parker, WindJack Solutions, Inc.
Currently, there is no really good way to create a general purpose popup calendar for use with Acrobat
Forms, but there are still a couple of ways that it can be done. The calendar presented here is composed entirely of Acrobat Form Fields and controlled through JavaScript. It was first developed a very long time ago by Jens Thomsen at Trisect Development in Denmark (www.trisect.dk), who provides it for free. It has been touched by several developers since then, and a few have even tried to productize it. The version presented here was modified by David Conorozzo at FormRouter (www.formrouter.com), and I consider it the very best update so far. It is much faster, and easier to use than the original. I further modified the code to handle popup calendars on multiple pages, something that none of the previous versions did.

Calendar UI
To see how the calendar works, press the button below.
Reset Form

After the calendar is activated it appears immediately above or below the field it’s associated with. To dismiss the calendar the user must either select a date or click the button a second time. Once the date is selected, the calendar will disappear and the formatted date is written into the associated form field.

Installing the Calendar on a PDF
1. The calendar is composed of regular Acrobat form fields. It is not a popup window, although it may look like one to the user. These form fields must be copied to every PDF page where the calendar is to be used.
a. Use the “Select Object” Tool to expose and select all of the calendar fields. You’ll find them immediately above the Date Field in the sample. All fields must be copied together, without changing the arrangement.
b. If the target page is rotated, all of the calendar fields will need to be rotated as well. And, a few of them may also need to be resized and moved into the correct alignment.
c. If the Calendar is overlapped over other fields on the form, then these fields may interfere with the operation of the calendar. To handle this situation do one of two things.
i. Place the target field so that the displayed calendar does not overlap any fields, ii. Select all the calendar fields, right click and select “Cut”, then right click and select Paste.
This action makes the calendar fields the last fields placed on the page and puts them at the bottom of the drawing order.
2. The other main part of the calendar is a Document Level Script that controls the calendar’s behavior.
In this document the script is called “FRCalendar”. Copy the entire contents of this script into a
Document Level Script with a similar name in the PDF where the calendar will be used.

www.pdfscripting.com

Copyright © 2009 by WindJack Solutions, Inc.

Activating the Calendar
The Calendar is set up and activated with a single function. See the code in the examples above and below.
In these samples the calendar is activated from a button MouseUp event, but the activation code could be called from any field or event. Calling this function a second time deactivates the Calendar. Resetting the
Calendar fields also deactivates the Calendar
This function associates the calendar with a particular text field, moves all calendar fields into position above or below the field, displays the calendar, and formats the selected date.
Activation