Skip to main content
Participating Frequently
January 20, 2024
Answered

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

  • January 20, 2024
  • 2 replies
  • 1330 views

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.

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

This topic has been closed for replies.
Correct answer Nesa Nurani

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 = "";}

2 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
January 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 = "";}
ItsGhaniAuthor
Participating Frequently
January 21, 2024

Worked like a charm! Thank you so much!

JR Boulay
Community Expert
Community Expert
January 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 Photoshopographe
ItsGhaniAuthor
Participating Frequently
January 21, 2024

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

JR Boulay
Community Expert
Community Expert
January 21, 2024

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

 

Acrobate du PDF, InDesigner et Photoshopographe