Highlighted

MULTIPLE FIELD CALCULATIONS

Community Beginner ,
Oct 15, 2020

Copy link to clipboard

Copied

Hi, Sorry to be asking again but I need some more help. 

I am trying to set up a PDF form in Acrobat 2017 to calculate the total of some cells. i.e    Field1 is CITY_RATE,  Field2 is COUNTRY_RATE, Field3 is NUMBER_DAYS and Field4 is TOTAL$ 

So if there is an entry in Field1 it is multiplied by Field3.  Using the calculate tab in properties I have been able to do this using "CITY_BFAST$, NUMBER_DAYS which does work.  But I want to set it up so that if I enter details in both Field1 & 2 they will both multiply by Field3 to give me a total in Field4 and this is where I am stumped.

Any assistance would be very much appreciated.

Try this in field4 as custom calculation script:

var f1 = this.getField("Field1").value;
var f2 = this.getField("Field2").value;
var f3 = this.getField("Field3").value;
event.value = f1*f2+f2*f3;

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

62

Likes

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

MULTIPLE FIELD CALCULATIONS

Community Beginner ,
Oct 15, 2020

Copy link to clipboard

Copied

Hi, Sorry to be asking again but I need some more help. 

I am trying to set up a PDF form in Acrobat 2017 to calculate the total of some cells. i.e    Field1 is CITY_RATE,  Field2 is COUNTRY_RATE, Field3 is NUMBER_DAYS and Field4 is TOTAL$ 

So if there is an entry in Field1 it is multiplied by Field3.  Using the calculate tab in properties I have been able to do this using "CITY_BFAST$, NUMBER_DAYS which does work.  But I want to set it up so that if I enter details in both Field1 & 2 they will both multiply by Field3 to give me a total in Field4 and this is where I am stumped.

Any assistance would be very much appreciated.

Try this in field4 as custom calculation script:

var f1 = this.getField("Field1").value;
var f2 = this.getField("Field2").value;
var f3 = this.getField("Field3").value;
event.value = f1*f2+f2*f3;

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

63

Likes

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
Oct 15, 2020 0
Contributor ,
Oct 15, 2020

Copy link to clipboard

Copied

So you just want field1*field2*field3?

Likes

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
Reply
Loading...
Oct 15, 2020 0
Community Beginner ,
Oct 16, 2020

Copy link to clipboard

Copied

Hi Asim123.  Unfortunately, field1*field2*field3 won't work.

I need something like:

Field1 * Field 3 + Field 2* Field3 with both results summed in Field 4 but i can't figure out how to make that happen

Likes

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
Reply
Loading...
Oct 16, 2020 0
Engaged ,
Oct 16, 2020

Copy link to clipboard

Copied

Try this in field4 as custom calculation script:

var f1 = this.getField("Field1").value;
var f2 = this.getField("Field2").value;
var f3 = this.getField("Field3").value;
event.value = f1*f2+f2*f3;

Likes

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
Reply
Loading...
Oct 16, 2020 0
Paul5D64 LATEST
Community Beginner ,
Oct 17, 2020

Copy link to clipboard

Copied

Thank NesaNurani,  I made one little tweak (changed event.value = f1*f2+f2*f3; to event.value = f1*f3+f2*f3;) and it worked perfectly, exactly what I was after.

I have been trying to learn everything I can from the web, tutorials etc.  but nothing can beat the expertise of people like yourself, so thank you again.

 

Likes

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
Reply
Loading...
Oct 17, 2020 0