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

Duplicate page on Form and renaming fields and updating those names in code

New Here ,
Sep 28, 2021 Sep 28, 2021

I have a form that has a button that will duplicate the page and will rename the fields on that new page. I am bad when it comes to coding so I got all of my code throgh scouring the internet. The code for that button is from here: https://community.adobe.com/t5/acrobat-discussions/how-can-you-duplicate-pages-without-having-the-fi...

the code that I am using for the button is:

// JavaScript to create duplicate pages from templates P1

var num_copies = 1; // Set the number of copies here

var T1 = getTemplate("AdditonalClass"); // Use the actual tempate name here

if (num_copies > 0) {

var oXObjT1 = T1.spawn({nPage: numPages, bRename: true, bOverlay: false});

if (num_copies > 1) {

for (var i = 1; i < num_copies; i += 1) {

T1.spawn({nPage: numPages, bRename: true, bOverlay: false, oXObject: oXObjT1});

}

}

}

This will duplicate the page and take the fields and rename them to PX.AdditonalClass.FeildName where X is the new page #.

 

I also have a check box that when checked duplicates the value of one field into several other fields with the code being:

if (getField("P4.Same Time 1 Check Box").value=="Yes")
getField("P4.Exam 2 Time 1").value = getField("P4.Exam 3 Time 1").value = getField("P4.Exam 4 Time 1").value = getField("P4.Exam 5 Time 1").value = getField("P4.Exam 6 Time 1").value = getField("P4.Exam 1 Time 1").value
else getField("P4.Exam 2 Time 1").value = getField("P4.Exam 3 Time 1").value = getField("P4.Exam 4 Time 1").value = getField("P4.Exam 5 Time 1").value = getField("P4.Exam 6 Time 1").value = "";

 

Is there a way that I can set the checkbox code to update based on what page it is on so when the button is pressed and creates a new page with the new field names the checkbox does not become useless? Also is there a way to set the button code to rename the field to PX.FeildName instead of PX.AdditionalClass.FeildName?

TOPICS
How to , JavaScript
973
Translate
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 ,
Sep 29, 2021 Sep 29, 2021
LATEST

In a script at the checkbox you will get the name of the checkbox with:

event.target.name

 

You can't change the field name with a script.

Translate
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