Copy link to clipboard
Copied
Im trying to make a form where if I hit a button all fields containing the word: "General" will be. changed to ""(nothing).
Is this possible?
Assuming these are text fields, you can do it using this code:
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f==null) continue;
if (f.type=="text" && /General/.test(f.valueAsString)==true) {
f.value = "";
}
}
Copy link to clipboard
Copied
Hi Flynn
Hope you are doing well and sorry for the trouble. As described, you want to make a form where if you hit a button all fields containing the word: "General" will be. changed to ""(nothing).
The workflow that you are trying to achieve is possible using the JavaScript. For more details pleae check the help page - https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_developer_guide.pdf
Regards
Amal
Copy link to clipboard
Copied
@Amal.
Thank you for sending this link over! I do love this book, it is the Koran for adobe acrobat. I have read "Chapter:11 Search and Index Essentials." but it did not seem to mention searching of fields and how to identify the name of the field searched.
Thank you for your reply!
-Flynn
Copy link to clipboard
Copied
You want to do it in all fields in file or just specific fields?
Copy link to clipboard
Copied
Assuming these are text fields, you can do it using this code:
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f==null) continue;
if (f.type=="text" && /General/.test(f.valueAsString)==true) {
f.value = "";
}
}
Copy link to clipboard
Copied
They are Dropdown fields.
Copy link to clipboard
Copied
So change this part of the code:
f.type=="text"
To:
f.type=="combobox"
Copy link to clipboard
Copied
Thank you!
where do you get this information from?
Copy link to clipboard
Copied
The JavaScript for Acrobat API Reference document, which is a part of the Acrobat SDK: https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/
Copy link to clipboard
Copied
Hi,
To clarify the workflow:
Is that correct?
Copy link to clipboard
Copied
"Is that correct?"
Yes