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

Need Script for Dynamic Replication of Fillable PDF Form Fields in Adobe Acrobat Pro

Explorer ,
Jan 20, 2024 Jan 20, 2024

Hello Adobe Community,
I am currently working on creating a fillable PDF form in Adobe Acrobat DC, and I'm facing a challenge that I believe some scripting expertise could help resolve.

In my form, I have 20 fields named Text1.0 to Text1.9 and Text 2.0 to Text2.9. What I'm looking for is a JavaScript script that, if I enter a value in Text1.3, the script should check Text2.0 to Text2.9 and replicate the value to the first available blank field starting from Text2.0. Similarly, if I enter a value in Text1.7, the script should search for blank fields in Text2.0 to Text2.9 and replicate the value to the next available blank field. And so on.
Screenshot 2024-01-20 161423.pngexpand image

Any guidance or script snippets that can help achieve this dynamic replication would be highly appreciated. Thank you in advance for your assistance!

TOPICS
Edit and convert PDFs , JavaScript , Modern Acrobat , PDF , PDF forms
889
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
1 ACCEPTED SOLUTION
Community Expert ,
Jan 20, 2024 Jan 20, 2024

Place this in one field as custom calculation script:

var str = [];
for(var i=0; i<=9; i++) {
var t1 = this.getField("Text1." + i).valueAsString;
if(t1 !== "")
str.push(t1);}

for(var j=0; j<=9; j++) {
var t2 = this.getField("Text2." + j);
if(j<str.length)
t2.value = str[j];
else
t2.value = "";}

View solution in original post

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 ,
Jan 20, 2024 Jan 20, 2024

Place this (not tested) script in all Text1. fields:

for (var i=0; i < 10; i++) {
	if (this.getField("Text2." +i).value == this.getField("Text2." +i).defaultValue) {
		this.getField("Text2." +i).value = event.value;
		break;
	}	
}

 


Acrobate du PDF, InDesigner et Photoshoptographe
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
Explorer ,
Jan 21, 2024 Jan 21, 2024

It replicates the value, however, when I move downward, it replicates all previously entered values again and again. Thank you btw!

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 ,
Jan 21, 2024 Jan 21, 2024

I tested my script and it works fine, see attachment.

 


Acrobate du PDF, InDesigner et Photoshoptographe
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
Explorer ,
Jan 21, 2024 Jan 21, 2024
LATEST

Yes, it's working fine. However, @Nesa Nurani's script autodeletes when someone removes a value and auto adjusts the priority when the value is entered above already entered values. Thank you so much for your help!

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 ,
Jan 20, 2024 Jan 20, 2024

Place this in one field as custom calculation script:

var str = [];
for(var i=0; i<=9; i++) {
var t1 = this.getField("Text1." + i).valueAsString;
if(t1 !== "")
str.push(t1);}

for(var j=0; j<=9; j++) {
var t2 = this.getField("Text2." + j);
if(j<str.length)
t2.value = str[j];
else
t2.value = "";}
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
Explorer ,
Jan 21, 2024 Jan 21, 2024

Worked like a charm! Thank you so much!

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