Loop Through Fields

Participant ,
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, How to, PDF forms

Views

505

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

Loop Through Fields

Participant ,
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, How to, PDF forms

Views

506

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
Jan 15, 2020 0
Adobe Community Professional ,
Jan 15, 2020

Copy link to clipboard

Copied

In the Acrobat Javascript Reference look at the method getNthFieldName

 

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
Reply
Loading...
Jan 15, 2020 0
Participant ,
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));
}

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
Reply
Loading...
Jan 15, 2020 0
Participant ,
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.

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
Reply
Loading...
Jan 15, 2020 0
Adobe Community Professional ,
Jan 15, 2020

Copy link to clipboard

Copied

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

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
Reply
Loading...
Jan 15, 2020 0
Most Valuable Participant ,
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.

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
Reply
Loading...
Jan 15, 2020 0
Adobe Community Professional ,
Jan 15, 2020

Copy link to clipboard

Copied

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

 

 

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
Reply
Loading...
Jan 15, 2020 0