Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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 = "";}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
It replicates the value, however, when I move downward, it replicates all previously entered values again and again. Thank you btw!
Copy link to clipboard
Copied
I tested my script and it works fine, see attachment.
Acrobate du PDF, InDesigner et Photoshoptographe
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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 = "";}
Copy link to clipboard
Copied
Worked like a charm! Thank you so much!

