How scripting works

Designer scripting uses an event-based model that allows you to alter various aspects of objects on a form at run time. As a form designer, you add scripts to objects based on when you want the script to execute. For example, you might place the following script on the click event of a button object so that at run time, when a user clicks the button, a message box appears with a message:

    xfa.host.messageBox("This is a message for a form filler.", "User Feedback", 3);

Scripts associated with a particular event execute whenever that event occurs. Some events can occur multiple times within the same form filling session. For example, the following script adds one to the current value of a numeric field:

    NumericField1.rawValue = NumericField1.rawValue + 1;

If you add this script to the calculate event for NumericField1, when you open the form for the first time, NumericField1 displays the value 2. This indicates that the calculate event occurred twice in the sequence of events that occurred when the form was opened.

// Ethnio survey code removed