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

Loop Through Fields

Participant ,
Jan 15, 2020 Jan 15, 2020

Copy link to clipboard

Copied

Can someone help me come up with a console code that prints the name of each field? I had it just hours ago, and I cannot locate it again, nor come up with it on my own.

TOPICS
Acrobat SDK and JavaScript

Views

3.0K

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 ,
Jan 15, 2020 Jan 15, 2020

Copy link to clipboard

Copied

In the Acrobat Javascript Reference look at the method getNthFieldName

 

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 ,
Jan 15, 2020 Jan 15, 2020

Copy link to clipboard

Copied

Right. So I need help fixing this:

for(var i = 0; i < this.numFields; i++){
console.println(i + ": " + this.getNthFieldName(i));
}

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 ,
Jan 15, 2020 Jan 15, 2020

Copy link to clipboard

Copied

Or even directly from the JS Ref:

for (var i = 0; i < this.numFields; i++)
console.println("Field[" + i + "] = " + this.getNthFieldName(i));

 I think I don't understand console exactly right. I put that in, highlight it all, and hit ctrl+enter. I get undefined.

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 ,
Jan 15, 2020 Jan 15, 2020

Copy link to clipboard

Copied

Did you open a document with form 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
Participant ,
Jan 15, 2020 Jan 15, 2020

Copy link to clipboard

Copied

I want to see a list of field names and their index numbers. A loop similar to this one was printing 31 lines of field names for me earlier, but I can't replicate it or find it again.

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 ,
Jan 15, 2020 Jan 15, 2020

Copy link to clipboard

Copied

The code above should work. Make sure you select all of it before pressing Ctrl+Enter, though.

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 ,
Jan 15, 2020 Jan 15, 2020

Copy link to clipboard

Copied

LATEST

You'll find a free tool here called "Find Required Fields". It loops through all the fields on a form and displays the ones that are required in a dropdown menu. It can easily be modified to show fields with any characteristic, or all of them.

https://www.pdfscripting.com/public/Free_Acrobat_Automation_Tools.cfm

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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