Monthly/Annually Fields update based on eachother's value

New Here ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

Hello! 

 

I am trying to make it so Monthly/Annually both update based on the value that is entered or updated.

Is it possible to get each of these 2 fields to update once either is filled in or when the value of either is changed? 

It seems i can get one field to calculate based on the other but not vice versa .

 

HolliyWell_0-1595023858701.png

event.value = Number(this.getField("txt_Annually").value) / 12;      in Monthly field

event.value = Number(this.getField("txt_Monthly").value) * 12;      in Annually field

I currently have these 2 calculations in each respective field. At the moment it doesnt allow you to alter the value inside the Monthly field.

 

Any advice would be greatly appreciated!

 

TOPICS
Acrobat SDK and JavaScript, How to, PDF forms

Views

58

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Jul 17, 2020 Jul 17, 2020
You can try it like this: //Place this code as custom calculation script of Monthly field if (event.source && event.source.name =="txt_Annually") {event.value = Number(this.getField("txt_Annually").value/12);} else event.value = event.target.value; //and place this code as custom calc script of the Annually field if (event.source && event.source.name =="txt_Monthly") {event.value = Number(this.getField("txt_Monthly").value*12);} else event.value = event.target.value; Note: Credit to Try67 wh...

Likes

translate

Translate

Translate
Adobe Community Professional ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

You can try it like this:

 

//Place this code as custom calculation script of Monthly field

if (event.source && event.source.name =="txt_Annually") {event.value = Number(this.getField("txt_Annually").value/12);}
else event.value = event.target.value;


//and place this code as custom calc script of the Annually field

if (event.source && event.source.name =="txt_Monthly") {event.value = Number(this.getField("txt_Monthly").value*12);}
else event.value = event.target.value;

 

Note: Credit to Try67 who coached me on how to apply (event.source && event.source.name)  a while ago.

 

This will allow both fields to calculate based on each other's values and remain editable.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2020 Jul 18, 2020

Copy link to clipboard

Copied

Thank you! Thought it might be something like this.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 18, 2020 Jul 18, 2020

Copy link to clipboard

Copied

You're welcome.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines