Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Searching all fields [Javascript]

Participant ,
Apr 29, 2021 Apr 29, 2021

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?

TOPICS
Create PDFs, Edit and convert PDFs, How to, JavaScript, PDF forms

Views

537

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Apr 30, 2021 Apr 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 = ""; } }

Likes

Translate

Translate
Adobe Employee ,
Apr 29, 2021 Apr 29, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 29, 2021 Apr 29, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 30, 2021 Apr 30, 2021

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 30, 2021 Apr 30, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 03, 2021 May 03, 2021

Copy link to clipboard

Copied

@try67 

They are Dropdown fields.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

So change this part of the code:

f.type=="text"

To:

f.type=="combobox"

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

@try67 

Thank you! 
where do you get this information from?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

LATEST

The JavaScript for Acrobat API Reference document, which is a part of the Acrobat SDK: https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 30, 2021 Apr 30, 2021

Copy link to clipboard

Copied

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?

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 30, 2021 Apr 30, 2021

Copy link to clipboard

Copied

"Is that correct?"

Yes

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines