Accessibility

LiveCycle Developer Center

LiveCycle Designer scripting samples

Expand your knowledge of LiveCycle Designer by using sample forms that demonstrate quick and simple solutions. These samples are grouped into task-based categories to help you identify the samples that most closely match your needs. Play with the sample forms and apply the techniques to your own work.

Send us a sample to have it posted here.


Stefan Cameron

Sample: Adding and removing table columns using scripting (ZIP, 186K)


Use the Instance Manager to change the number of columns in a table.


Alex Mitchell

LiveCycle Designer Scripting Basics (LiveCycle Designer 8.0)


Learn how you can use calculations and scripts to develop and enhance forms created in LiveCycle Designer.


Scripting

As part of the form authoring design process, you can choose to add calculations and scripts to provide a richer experience for form recipients. The sample forms below are intended to help you better understand scripting in LiveCycle Designer, and provide quick solutions to scripting tasks.

Getting and setting form field values

Learn how to manipulate the values of field objects, including images, on your form design.

Sorting list boxes and drop-down lists (ZIP, 94K)

Use the JavaScript Array object’s built-in sorting function to sort pairs of text and value items at runtime. Developed by Stefan Cameron (August 28, 2006).

Processing all fields on a form (ZIP, 316K)

This sample demonstrates how to find and perform actions on specific types of form fields. Developed by Stefan Cameron (August 14, 2006).

Validating field content in a form hosted in Adobe Acrobat (ZIP, 91k)

This sample demonstrates how to use the Acrobat Scripting API within an XFA form to make invalid fields flash red when you attempt to submit the form. Developed by Stefan Cameron (July 31, 2006).

Manipulate values in a choice list (ZIP, 81k)

These examples demonstrate different ways to manipulate the value(s) of a choice list.

Display different images inside the same image field (ZIP, 208k)

This example demonstrates how to dynamically change the value of an image field.

Save and load XML data at runtime (PDF, 130k)

This example demonstrates the results you can obtain using the saveXML() and loadXML() XML Form Object Model methods.

Calculate the field sums (PDF, 89k)

This example demonstrates how to calculate the sums of fields located at different levels of the form hierarchy.

Display a numeric field's value in a different format (PDF, 85k)

This example demonstrates different properties of the Adobe XML Form Object Model that display the value of a field.

Reset the values of the current subform (PDF, 90k)

This example shows how to reset the values of a specific set of fields, not the whole form. To do this, only reset the fields in the desired subform object.

Getting the current or previous value of a drop-down list (PDF, 357k)

This example demonstrates how to obtain the current value of a drop-down list as well as the different ways to access the previous value of a drop-down list on a form.

Changing the appearance and behavior of an object at runtime

Learn how to alter characteristics of a form object such as appearance, visibility on the form, and behavior based on user interaction with the form.

Creating image hotspots on PDF forms (ZIP, 102K)

Learn how to create hotspots on images by using JavaScript objects from Adobe Acrobat. Developed by Stefan Cameron (Nov. 20, 2006).

Adding subform instances at runtime (ZIP, 148K)

This sample demonstrates how to add subform instances to your form at runtime and include the new subform as well as its child objects in any form calculations. Developed by Stefan Cameron (July 17, 2006).

Developing a form with multiple and expandable question fields (PDF, 170k)

This sample demonstrates how to expand multiple text fields to accommodate unlimited text answers. Submitted by Niall O'Donovan .

Adding and removing subforms at runtime (PDF, 513k)

This example demonstrates how to add subforms to and remove subforms from a form at runtime.

Adding and removing table rows at runtime (PDF, 515k)

This example demonstrates how to add rows to and remove rows from a table at runtime.

Techniques for changing the presence attribute of a button (PDF, 94k)

These examples demonstrate different ways to control the presence attribute of a button object. To properly view the third example, you will need to open the form in LiveCycle Designer.

Change the fill color of a field (PDF, 333k)

This example demonstrates how to change the fill color of a field at runtime.

Set focus on objects on the master page and body page (PDF, 125k)

This example demonstrates the different techniques required to create a script for an object on the body page versus creating a script for an object on the master page. The example uses setFocus.

Adjust the height of a field at runtime (PDF, 333k)

This example demonstrates how to expand a field to match the height of the content in another field.

Set a field as required at runtime (PDF, 82k)

This example uses scripting to make a field a required field at runtime.

Remember the state of field properties changed by scripting (dynamic PDF) (PDF, 343k)

Field properties changed via scripting should be remembered when you navigate the pages of an HTML form. The same applies when you reopen a dynamic PDF form. In the case of a PDF form, scripting is required to remember the state of the fields.

Set the URL of a submit button at runtime (PDF, 86k)

This example demonstrates how to email a form to an address specified by the person filling the form.

Hide a text string in an Acrobat 6.0 compatible form (PDF, 149k)

In Adobe Acrobat 6.0, static objects become part of the page. For example, you cannot change the presence of static text at runtime. This sample provides a solution for making the text visible and invisible at runtime. You need to open this form in LiveCycle Designer to properly view the example.

Intelligent Expense Report with dynamic subforms and calculations (PDF, 615k)

This example demonstrates dynamic subforms and automatic calculations at runtime. Download this Intelligent Expense Report and you will see how interactive PDF enables you to create expense items on the fly and how intelligent PDF performs all of the calculations while you work. Contributed by SmartDoc Technologies.

Highlighting fields in response to user interaction (PDF, 174k)

This example demonstrates how to highlight the current field that a form filler is working with, highlight fields that a form filler is required to fill, and use message boxes to provide feedback to a form filler.

Changing the visual properties of an object at runtime (PDF, 187k)

This example demonstrates how to manipulate the visual properties of an object; in this case, a text field.

Hiding and showing objects (PDF, 180k)

This example demonstrates how to hide buttons when printing a form, as well as how to hide and show objects at runtime.

Changing the background colors of fields, fillable areas, and subforms at runtime (PDF, 513k)

This example demonstrates how to change the background color of fields, fillable areas, and subforms on a form, based on user interactions, at runtime.

Changing the background color of rows and tables at runtime (PDF, 193k)

This example demonstrates two methods for changing the background color of rows and tables, based on user interaction, at runtime.

Working with data sources and schemas

Learn how to work with various data sources, such as XML data files and databases, as well as how to use XML schemas.

Sample: Obtaining data from URL requests (ZIP, 216K)

Use URL requests to pass parameters into a PDF form. Developed by Stefan Cameron .

Sample: Displaying all records from a database on your form (ZIP, 98K)

Display all records from an ODBC data connection simultaneously for reporting purposes. Developed by Stefan Cameron .

Sample: Displaying specific database records on your form (ZIP, 174K)

Learn how to use LiveCycle Designer to filter records in a database and populate a form with the resulting data. Developed by Stefan Cameron .

Connecting a form to a database (ZIP, 156K)

Learn how to connect to and display records from a database. Developed by Stefan Cameron .

Localizing forms without writing any scripts (ZIP, 100K)

Learn how to use the Dynamic Properties feature in LiveCycle Designer to localize field captions using XML Data files. Developed by Stefan Cameron .

Adding data to a list without writing any scripts (ZIP, 100K)

Learn how to use the new Dynamic Properties feature in LiveCycle Designer 7.1 to automatically add items to lists instead of writing the script on your own. Developed by Stefan Cameron .

Creating data-nominated subforms (ZIP, 22k)

This sample demonstrates how to map specific subforms to specific data records by using the new Data-Nominated Subforms feature in LiveCycle Designer 7.1. Developed by Stefan Cameron .

Import data into a pre-populated form (ZIP, 128k)

This example demonstrates how to maintain pre-populated data when importing new data. For example, a customer can fill and submit a form. The person who receives the form needs to import additional data into the submitted form. The form requires scripting to "remember" the pre-populated data when new data is imported.

Techniques for specifying a data file (ZIP, 19k)

The first two examples are methods for exporting data. In the first example, the script doesn't supply a file name, so the form prompts the user to give the exported data file a name. In the second example, the script specifies a file name, so a prompt for the user is not required. In the third example, the form is importing data, and the form prompts the user for the data file.

Using a table to display data stored in a data file (ZIP, 163k)

This example demonstrates how to load data from an XML data file into a table. In this case, the table grows to accommodate the number of data entries stored in the data file.

Browsing records stored in a data file (ZIP, 353k)

This example demonstrates how to navigate through records stored in an XML data file by using buttons to navigate between records.

Applying form layout and pagination techniques

Use the Instance Manager to change the number of columns in a table.

Sample: Adding and removing table columns using scripting (ZIP, 186K)

Learn how to create customized form layouts and pagination using scripting, as well as the capabilities of LiveCycle Designer objects. Developed by Stefan Cameron (April 23, 2007).

Sample: Adding a table of contents to a form (ZIP, 155K)

Learn how to use layout techniques to add a dynamic table of contents to your forms. Developed by Stefan Cameron (December 4, 2006).

Adding subform instances using the addInstance method (ZIP, 89K)

Learn how to use the addInstance method to add subform instances at runtime. Developed by Stefan Cameron (September 11, 2006).

Specifying conditional page breaks (ZIP, 95K)

This sample demonstrates how to specify conditional page breaks depending on imported data values. Developed by Stefan Cameron

Display the field's value into a comb-like layout (PDF, 132k)

This example demonstrates how to convert an existing field value into a comb-like layout.

Display two columns of data with different lengths side-by-side (PDF, 152k)

This example displays two columns of subforms side-by-side. The subforms of the left column are allowed to repeat. The first subform of both columns should be displayed side-by-side even when the content of one column flows onto a new page.

Create a table with one row and two columns where the content of the row is allowed to break between pages. Pay attention to the paragraph alignment of the subforms because it will affect how its content is displayed.

Working with digital signatures

Learn how to incorporate digital signatures into your form designs.

Signature events (PDF, 118k)

This example shows the relationship between events when the signature is applied, cleared, or cancelled.