Skip to main content
Participant
August 31, 2016
Answered

Auto Populated Fields do not Update/Populate after making a correction to field

  • August 31, 2016
  • 1 reply
  • 645 views

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

This topic has been closed for replies.
Correct answer George_Johnson

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;

1 reply

Inspiring
August 31, 2016

Where did you place that code? If in a field event, what is the field name and what is the event?

DC-jr7138Author
Participant
August 31, 2016

George_Johnson:

Thanks for your question. I placed it here:

with an "On Blur" and runs as JavaScript.

jr7138

George_JohnsonCorrect answer
Inspiring
August 31, 2016

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;