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

Trying to locate duplicate form fields

Explorer ,
May 22, 2020 May 22, 2020

Copy link to clipboard

Copied

I am troubleshooting an Acrobat form with a lot of Yes/No checkboxes. I've created separate group names for each set of boxes, but apparently there are duplicates somewhere, for when I tried to make copies of the fields (to edit afterwards) I got the message "Cannot create multiple copies of this selection. One or more fields in the selection have duplicated in this form."

 

So I searched the community here and found a javascript to locate duplicate fields:

for (var i=0; i<this.numFields; i++) {
    var f = this.getField(this.getNthFieldName(i));
    if (f==null) continue;
    if (f.type=="text" && typeof f.page=="object") {
        console.println(f.name + ":" + f.page);
    }
}

and ran it in the Javascript Consol/Debugger, but I would get the error message:

SyntaxError: syntax error
1:Console:Exec
undefined

so am I doing something wrong? 

 

Each button already has a run javascript action on mouse up, could that be interfering somehow?

if (event.shift) event.target.value = "Off"

 Any help would be greatly appreciated.

TOPICS
General troubleshooting , PDF forms

Views

2.2K

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 2 Correct answers

Community Expert , May 23, 2020 May 23, 2020

Select the whole code and execute it.

 

The code will find duplicate form text fields.

Votes

Translate

Translate
Community Expert , May 25, 2020 May 25, 2020

Correct. You can remove this part of the code (which I believe I wrote, by the way) to process all fields, not just text fields:

f.type=="text" && 

However, this means that it will list all radio-buttons and check-boxes which have more than one widget in the group.

To avoid that you can replace the above with this:

f.type!="radiobutton" && f.type!="checkbox" &&

Then it will report about duplicate fields of all other types, except those two.

Votes

Translate

Translate
Community Expert ,
May 23, 2020 May 23, 2020

Copy link to clipboard

Copied

Select the whole code and execute it.

 

The code will find duplicate form text 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 23, 2020 May 23, 2020

Copy link to clipboard

Copied

You'll find a tutorial here on using the console window:

https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro

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
Explorer ,
May 25, 2020 May 25, 2020

Copy link to clipboard

Copied

Ok, I ran it and it came back with "undefined" so that would mean no duplicate 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 25, 2020 May 25, 2020

Copy link to clipboard

Copied

Then you have no duplicate text 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 25, 2020 May 25, 2020

Copy link to clipboard

Copied

LATEST

Correct. You can remove this part of the code (which I believe I wrote, by the way) to process all fields, not just text fields:

f.type=="text" && 

However, this means that it will list all radio-buttons and check-boxes which have more than one widget in the group.

To avoid that you can replace the above with this:

f.type!="radiobutton" && f.type!="checkbox" &&

Then it will report about duplicate fields of all other types, except those two.

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