• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

1.8K

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

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

Votes

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

Votes

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

Votes

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?

Votes

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

Votes

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.

Votes

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
Community Expert ,
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"

Votes

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?

Votes

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
Community Expert ,
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/

Votes

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
Community Expert ,
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?

 

Votes

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
Community Expert ,
Apr 30, 2021 Apr 30, 2021

Copy link to clipboard

Copied

"Is that correct?"

Yes

Votes

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