Copy link to clipboard
Copied
Example:
We have a employee name field throughout the document:
Employee Name_1 on page 1
Employee Name_2 on page 2
Employee Name_3 on page 8
Employee Name_4 on page 10
So the script is on the first Employee Name_1, and it works fine. Type your name and the three other fields populate like magic.
Save the PDF, go get a coke or potty break.
Open the saved PDF and you see a typo on the Employee Name_1 field, so you correct. Ah, now it doesn't auto populate the rest of the employee_name fields:
Here is my script:
//set the vars
var one = this.getField("Employees Name_1");
var two = this.getField("Employees Name_2");
var three = this.getField("Employees Name_3");
var four = this.getField("Employees Name_4");
//this function that checks if the destination field is blank and if so popluates it.
function checkAndPopulate(orig,populate){
if(populate.value==''||populate.value==null){populate.value=orig.value}
}
//copy value of one to two, three and four
checkAndPopulate(one,two);
checkAndPopulate(one,three);
checkAndPopulate(one,four);
Not sure where my error my be?
Any help?
thanks,
jr7138
I'd recommend not using the On Blur event and instead place the script in the validate event of the Name_1 field. If you want it to update the values of the other fields when it is updated, regardless of whether they are blank or not, the script can be simplified to the following:
// Custom Validate script for Name_1 field
getField("Name_2").value = event.value;
getField("Name_3").value = event.value;
getField("Name_4").value = event.value;
Copy link to clipboard
Copied
Where did you place that code? If in a field event, what is the field name and what is the event?
Copy link to clipboard
Copied
The checkAndPopulate function is set up to update the specified field only if it's currently blank (sort of). If that's not what you want, you'll have to change it.
Copy link to clipboard
Copied
George_Johnson:
Thanks for your question. I placed it here:

with an "On Blur" and runs as JavaScript.
jr7138
Copy link to clipboard
Copied
I'd recommend not using the On Blur event and instead place the script in the validate event of the Name_1 field. If you want it to update the values of the other fields when it is updated, regardless of whether they are blank or not, the script can be simplified to the following:
// Custom Validate script for Name_1 field
getField("Name_2").value = event.value;
getField("Name_3").value = event.value;
getField("Name_4").value = event.value;
Copy link to clipboard
Copied
George_Johnson:
Thanks for your great help. Your recommendation was spot on. Worked like a charm.
Best regards,
jr7138
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more