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. In addition to the actual scripts
that set the current and previous values, it is important to note
that the scripts are located on the
change
event
for the drop-down list.
In the following example, when a form filler selects a value
from the drop-down list, the selected value appears in the Current
Value field. Then, when the form filler selects another value from
the drop-down list, the new value appears in the Current Value List
and the previous value appears in the Previous Value 1 field.
Note:
Each of the methods for obtaining the previous
value of a drop-down list uses a different script. The Previous
Value 1 text field is populated by a direct reference to the
rawValue
property
of the drop-down list, whereas the Previous Value 2 text field is
populated using the
prevText
property. For consistent
results, it is recommended that you access the previous value by
using the
prevText
property.
To see this scripting example and others, visit the visit the
Developer
Center
.
Scripting for populating the Current Value text field
Populate the value of the Current Value text field
by using the
newText
property:
CurrentValue.rawValue = xfa.event.newText;
Scripting for populating the Previous Value 1 text field
Populate the value of the Previous Value 1 text
field by referencing the
rawValue
of the drop-down
list:
PreviousValue1.rawValue = DropDownList.rawValue;
Scripting for populating the Previous Value 2 text field
Populate the value of the Previous Value 2 text
field by using the
prevText
property:
PreviousValue2.rawValue = xfa.event.prevText;