Home / Articles / How to Create Scripts for Online Forms with Adobe LiveCycle Designer

How to Create Scripts for Online Forms with Adobe LiveCycle Designer

Chapter Description

Digital forms expert J.P. Terry shows you how to improve the functionality and usability of your online forms through scripting.

The Script Editor

The Script Editor is the tool you use to create and edit scripts. You can view the Script Editor in either single or multiline view. Unless you are creating one-line scripts in FormCalc, you should use the multiline view. The multiline view provides a number of features that the single-line view does not. To switch between the multiline view and the single-line view, click and drag the Script Editor palette bar until the palette is the required size (Figure 4.3).

Figure 4.3

Figure 4.3 Click and drag the Script Editor palette bar to switch from single to multiline view. If you single click on the palette bar, the Script Editor toggles open and closed.

If you cannot see the Script Editor on your screen, select Window > Script Editor.

The Script Editor in Single-line View

Figure 4.4 shows the Script Editor in single-line view. Notice how small the script editing window is. Even my very short script was truncated. This example shows the Print button from the Contact Information form.

Figure 4.4

Figure 4.4 The Script Editor in single-line view.

The Script Editor shows the following information in both single and multiline view:

  • Event: In this case the event is the button's click event. The asterisk indicates that there is script in this event. If you select the event drop-down menu, you will see all of the events for this object. Grayed out events are not available for this form object.
  • Script editing window: This is where you write and edit your scripts.
  • Enter/Cancel a script source change: These buttons commit or cancel your script source changes to your XML source. If you do not commit your script changes with this button, they may not execute properly when you select Preview PDF. These buttons were removed in Designer ES.
  • Script Language specification: In this case, the Language is set to JavaScript. Even if you put proper FormCalc script into this box, it will not work.

The Script Editor in Multiline View

You should use multiline view if you are working with JavaScript. In addition to showing your complete script, the multiline view also provides more features than the single-line view (Figure 4.5).

Figure 4.5

Figure 4.5 The Script Editor in multiline mode provides additional options.

  • Functions button: While you are working in the script editing field, you can click this button to view a list of FormCalc or JavaScript functions depending on your Language setting.
  • Show events for child objects: This feature is a welcomed improvement in LiveCycle Designer 8. You can now see all of the scripts for a subform, a page, or for your entire form at once. Prior to the addition of this feature, it was very difficult to find all of the scripts that were hidden in different parts of a complex form. This option shows all of the scripts for the currently selected object and all of its child objects. If you select the top form object in the hierarchy, this option displays all of the scripts associated with a specific event. Alternatively, you can change from a specific event to view all events by selecting Events with Scripts to see every script in your form.
  • Run At specification: This option specifies where your script will run. The Run At specification in Figure 4.5 is Client, which means the script will be processed by Acrobat, Adobe Reader, or a Web browser. If the specification is set to Server, the script is processed by LiveCycle Forms. If LiveCycle Forms is not part of your system, you should always use the Run At Client option. The third Run At option is Client and Server. Use this setting when you are not sure if your form will be rendered on a client or a server, or for forms that may be rendered on both the client and the server at different times. For instance, if your form will be used as a self-contained PDF file and as an XDP file that will be processed by LiveCycle Forms into an HTML form, use the Client and Server setting for your scripts.

    You can choose this option when you want the server to recalculate and/or revalidate submissions that were first calculated in the client application. You can also use this option when you are creating HTML forms with the LiveCycle Forms product. If you have a script that cannot function in the HTML client environment, it will be passed back to the server for processing if the Run At specification is set to Client and Server.

The Check Script Syntax tool in Designer ES

Designer ES includes the Check Script Syntax tool (Figure 4.6) as part of the Script Editor. This tool provides some basic syntax checking for FormCalc and JavaScript, and is discussed in the "Debugging Scripts" section at the end of this chapter.

Figure 4.6

Figure 4.6 The Check Script Syntax tool is included in the Script Editor of Designer ES.

4. Basic Scripting | Next Section Previous Section