Scripting Sample

The Scripting sample helps you to experience scripting with the FormCalc and JavaScript languages. You can enter a script into a box and run it by clicking a button. The sample includes a variety of field types that the script can use.

The sample includes the file named Scripting.pdf. Both the form design and the form that the user will interact with are located in the Forms folder.

To run the Scripting sample

  1. Open the Scripting.pdf form, located in \EN\Samples\Forms\Scripting\Forms, in either Acrobat or Adobe Reader.

  2. Enter a script in the Enter Your Script Here field.

  3. Enter any input that is expected by the script.

  4. Click the appropriate button to run the script. Any output appears in the Result field. If you prefer, you can assign the results to another field.

  5. After the script runs, click Clear Fields in order to clear the fields to rerun or alter the script.

    To try a simple script, use one of these samples.

JavaScript

if (NF1.rawValue < NF2.rawValue) 
    NF3.rawValue = 0 
else 
       NF3.rawValue = NF1.rawValue - NF2.rawValue

FormCalc

if (NF1 < NF2) then 
    NF3 = 0 
else 
    NF3 = NF1 - NF2 
endif

Both scripts use the numerical fields NF1, NF2, and NF3. The user can type numbers into the NF1 and NF2 fields, and the script subtracts the numbers (NF1-NF2) and displays the difference in the NF3 field. If the result is negative, the NF3 value is set to 0.

// Ethnio survey code removed