Adobe 12001196 Scripting Guide - Page 55
Using Acrobat JavaScript in Forms, Creating simple JavaScripts, Creating an automatic date field
UPC - 718659085742
View all Adobe 12001196 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 55 highlights
4 Using Acrobat JavaScript in Forms Creating simple JavaScripts There are a number of simple JavaScripts you can integrate into your forms to enhance their interactive capabilities. The scripts described here are commonly used with Acrobat forms. Trying out these scripts in the forms you create will give you a glimpse of what JavaScript offers. Careful selection of field names when creating forms is an important factor in data collection. If two fields share the same name, they also share the same value. You can use this capability to create fields that have different appearances (that is, appear on different pages and have different background colors) but have the same value. This means you can modify one field and the other field is updated automatically. NOTE: In order to create and use JavaScript in Acrobat, you must have JavaScript enabled. Make sure that JavaScript is enabled by choosing Edit > Preferences > General and selecting JavaScript from the list on the left. Select Enable Acrobat JavaScript if it is not already selected, and click OK. Creating an automatic date field Many forms require a date for tracking purposes. The following procedure shows you how to create a text field that automatically displays the current date when the document is opened. The script you create to display the current date when the document is opened is a document level script. To create an automatic date field: 1. Select the form tool , and create a text field. (For more information, see the section on Creating Form Fields in the Acrobat online help.) Select the General tab and name the field Today. 2. Select the Format tab, choose Date for the format category, and choose a month, day, and year format option (for example, "mmm d, yyyy"). On the General tab, make sure the field is read-only because it will be a calculated field, and click Close. 3. To create a document level script that is executed each time the document is opened, choose Advanced > JavaScript > Document JavaScripts. Name the script Today, and click Add. Acrobat JavaScript Scripting Guide 55