Skip to main content
Participant
January 8, 2025
Answered

Column Numbers Changing for No Reason - Help!

  • January 8, 2025
  • 1 reply
  • 1301 views

Hello,

 

I'm working on a fillable form (attached). I'm using Adobe Acrobat.

 

As I am testing it, the Monthly Desired Income (column) dollar amounts show up properly. However when I move to the next column (Social Security) and input a number (1.5%), the Monthly Desired Income numbers change automatically (to two $8000 but it should be $8000 and then $8240). My screenshot is attached. I do not want this automatical change. 

 

The current script for the Monthly Desired Income is:

 

var v1 = event.target.value = this.getField("Objective70").value;

var v2 = event.target.value = this.getField("Objective71").value;

var v3 = 0.01

var v1_2 = v1*v2;

var v3_4 = v1_2*v3;

if (v3_4==0) event.value = "";

if (v2==0) event.value = event.target.value = this.getField("Objective72").value;

else event.value = v2 + v3_4;

 

A screenshot of this is also attached. I need the Monthly Desired Income column to perform this calculation as well as be editable (i.e. someone may need $8000 at age 65 and then at age 90 they may need only need $9000 even though the automatic calculation will say $16750).

 

Help, how can I fix this? What is the proper custom calculation script?

 

I appreciate your time!

 

 

Correct answer PDF Automation Station

When a field is calculated, you can't enter any other value because it will always revert to the calculated value.  Every calculation runs every time any field value changes.  Validation scripts, on the other hand, only run when the value of the field they are in changes.  I would recommend you remove all calculations in that column and put the following validation script in the Objective71 field (after you change the names of Obj100 and Obj101 to Objective100 and Objective101:

this.calculate=false;
var percnt=this.getField("Objective70").value/100;
var amount=event.value;
for(var i=72;i<102;i++)
{
this.getField("Objective"+i).value=amount*(1+percnt);
amount=this.getField("Objective"+i).value;
}
this.calculate=true;
this.calculateNow();

https://pdfautomationstation.substack.com/p/calculation-vs-validation-scripts

https://pdfautomationstation.substack.com/p/calculation-vs-validation-scripts-eb5

https://pdfautomationstation.substack.com/p/another-method-for-calculation-vs

1 reply

PDF Automation Station
Community Expert
Community Expert
January 8, 2025

Remove all instances of this:

 = event.target.value

Participant
January 10, 2025

Thank you,  I removed the = event.target.value from the Monthly Desired Income column.

However, I'm not able to customize it anymore (i.e. say if I wanted to put $9000 at age 90, it still says $16750). 

My screenshot and updated form is attached.

Is there another custom script that I can use?

I appreciate your help!

 

PDF Automation Station
Community Expert
Community Expert
January 11, 2025

When a field is calculated, you can't enter any other value because it will always revert to the calculated value.  Every calculation runs every time any field value changes.  Validation scripts, on the other hand, only run when the value of the field they are in changes.  I would recommend you remove all calculations in that column and put the following validation script in the Objective71 field (after you change the names of Obj100 and Obj101 to Objective100 and Objective101:

this.calculate=false;
var percnt=this.getField("Objective70").value/100;
var amount=event.value;
for(var i=72;i<102;i++)
{
this.getField("Objective"+i).value=amount*(1+percnt);
amount=this.getField("Objective"+i).value;
}
this.calculate=true;
this.calculateNow();

https://pdfautomationstation.substack.com/p/calculation-vs-validation-scripts

https://pdfautomationstation.substack.com/p/calculation-vs-validation-scripts-eb5

https://pdfautomationstation.substack.com/p/another-method-for-calculation-vs