Using form elements and scripting to create interactive forms

In this recipe, we will see how we can create a simple interactive form with form elements and some script written in FormCalc language. We will create an example where we create three fields on the screen and a button that will calculate the total of the value of the first two fields and display within the third field.

Getting ready

From the Adobe LiveCycle Designer, choose the menu option Edit and then select Form Properties. On the Defaults tab, within the Preview block, select Interactive Form within the Preview Type drop-down list and Acrobat 8 (Dynamic) XML Form for the XDP Preview Format drop-down list.

Getting ready

How to do it...

Follow these steps:

  1. We create a new interface. We add three amount fields in the global definition of the interface.
    How to do it...
  2. We create a new form using the interface and include the three variables defined in the interface. On the layout editor, add three fields for each of the three variables created earlier in the context. This will create three decimal fields on the layout.
  3. Then add a button and give it the caption Total.
    How to do it...
  4. For the Amount 1 and Amount 2 fields, we set the Display Pattern drop-down list as $9,999.99 using the Field tab on the Object palette.
    How to do it...
  5. For the two fields, we will set the Type drop-down list as User Entered – Required on the Value tab.
    How to do it...
  6. While being in the Design View window, click on the button that was created in the previous steps. Make sure the Scripting palette is visible. Then, from the list box of Scripts, choose the Click event. The script editor appears as shown in the following screenshot. Write the following code in the script editor and then activate.
    How to do it...

How it works...

We can see the PDF Preview window by clicking on the Preview PDF tab in the layout editor. We can only enter a maximum of two decimal places. Any amount entered in the first two fields is shown in the format specified. For example, if we enter 1200.78, it will be changed to $1,200.78. When the Total button is pressed, the two values are totaled and shown in the Total field. Upon clicking the Total button, the script for the button-click event of the button is executed. The totaling is done and then displayed.

How it works...

There's more...

We may also test the form through the Test button of transaction SFP. In this case, the SFP transaction will take us to the function module test screen. For testing the interactive scenario, the FILLABLE field for the /1BCDWB/DOCPARAMS structure must be passed the value 'X'. This will open the PDF form in the interactive mode, as shown in the following screenshot:

There's more...
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.138.14