Skip to main content
This topic has been closed for replies.
Correct answer try67

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 = "";
	}
}

3 replies

BarlaeDC
Community Expert
Community Expert
April 30, 2021

Hi,

 

To clarify the workflow:

 

  1. User presses button
  2. You search every form field for the fields that contain "General"
  3. If you find any, all the field you finds will have the entire contents set to ""

 

Is that correct?

 

JR Boulay
Community Expert
Community Expert
April 30, 2021

"Is that correct?"

Yes

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 30, 2021

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 = "";
	}
}
Flynn0101Author
Inspiring
May 4, 2021

@try67 

They are Dropdown fields.

try67
Community Expert
Community Expert
May 4, 2021

So change this part of the code:

f.type=="text"

To:

f.type=="combobox"

Amal.
Legend
April 30, 2021

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

Flynn0101Author
Inspiring
April 30, 2021

@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

Inspiring
April 30, 2021

You want to do it in all fields in file or just specific fields?