Reputation: 809
I am working with JavaScript in Adobe Acrobat and want to assign a mouseUp event to multiple fields on document load. Is that possible or do I have to go into each field and manually select properties -- > Actions and so on ?
I imagine something like this
var fg = this.getField(nameOfFieldGroup).getArray();
for (var i = 0; i < fg.length; i++) {
if (this.getField(fg[i]).required) {
// assign a mouseUp event to that field here.
}
}
Upvotes: 0
Views: 1463
Reputation: 4917
The Field.setAction() method will let you add scripts to a field. You only need to do this once, not every time the document loads. The script in the second parameter is the string that you want to be executed when the specified event fires. In the example below, it's just a beep.
this.getField(fg[i]).setAction("MouseUp", "app.beep(0);");
Upvotes: 1