Adobe 12001196 - Acrobat - Mac Manual page 68

Javascript
Hide thumbs Also See for 12001196 - Acrobat - Mac:
Table of Contents

Advertisement

Using Acrobat JavaScript in Forms
4
Creating form fields programmatically
Table Notes.
Item and Export Value: After a combo box is created with addField. the item names
their export values can easily be introduced using setItems; for example
["Arizona", "AZ"] ]);
Sort: There is no direct hook to this check box on the Options tab. This check box tells
Acrobat to sort the list as it is entered in the UI. In the above example of setItems, the
items are not entered in alphabetical order. Programmatically, the list can be sorted
using the sort method of the array object. For example:
Actions Tab
The Actions tab shows the same set of properties as for buttons. For details, see the
Actions Tab
Format Tab
The action of the combo box can be set with the field level
of "Format". The UI has several categories of formatting, the JavaScript counterparts are
listed in the table below. Except for custom formatting, all formats can be realized by using
the formatting functions contained in Javascripts\aform.js.
Region/Name See Reference
Number
Percentage
Date
68
f.setItems([ ["California", "CA"], ["Ohio", "OH"],
function compare (a,b) {
if (a[0] < b[0] ) return -1;
if (a[0] > b[0] ) return 1;
return 0;
}
var tmp = new Array();
var f = this.getField("myCombo");
for (var i = 0; i < f.numItems; i++)
tmp[i] = [f.getItemAt(i,false), f.getItemAt(i)];
tmp.sort(compare);
f.clearItems();
f.setItems(tmp);
for buttons.
AFNumber_Format()
Javascripts\aform.js
AFPercent_Format()
AFDate_FormatEx()
// define a compare function
// load [item, exportvalue]
// sort of first component
// out with the old
// in with the new
setAction
Example
in
f.setAction("Format",
'AFNumber_Format(2, 0, 0, 0,
"\u20ac", true)');
f.setAction("Keystroke",
'AFNumber_Keystroke(2, 0, 0, 0,
"\u20ac", true)');
and a trigger name
Acrobat JavaScript Scripting Guide

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Acrobat 6.0

Table of Contents