Highlighted

conditional calculation in acrobat

New Here ,
Aug 25, 2020

Copy link to clipboard

Copied

I'm working on a PDF order form and know nothing about Java.

I need to calculate the in-state shipping cost (Field1) based on whether the buyer selected YES for in-state (Field2).

The calculation would be Subtotal Price (Field3) * .20. In other words, the in-state shipping cost is 20% of the order subtotal.

I'll need a calculation for out-of-state shipping based on similar fields with a cost that is 30% of the order subtotal.

Thanks for any help/

TOPICS
Acrobat SDK and JavaScript

Views

44

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

conditional calculation in acrobat

New Here ,
Aug 25, 2020

Copy link to clipboard

Copied

I'm working on a PDF order form and know nothing about Java.

I need to calculate the in-state shipping cost (Field1) based on whether the buyer selected YES for in-state (Field2).

The calculation would be Subtotal Price (Field3) * .20. In other words, the in-state shipping cost is 20% of the order subtotal.

I'll need a calculation for out-of-state shipping based on similar fields with a cost that is 30% of the order subtotal.

Thanks for any help/

TOPICS
Acrobat SDK and JavaScript

Views

45

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
Aug 25, 2020 0
Adobe Community Professional ,
Aug 25, 2020

Copy link to clipboard

Copied

You don't need Java, Acrobat uses Javascript.

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...
Aug 25, 2020 0
New Here ,
Aug 25, 2020

Copy link to clipboard

Copied

Sorry, I meant Javascript. That's how little I know.
I've been able to get the field to calculate from other answers that use a set number, i.e., if in-state, then value is 10.

But I can't get it to calculate the subtotal price *.20.
This is what I have that does not work:

var v = this.getField("Field2").valueAsString;
if(Field2 =="YES")event.value = "Field3*0.20";

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...
Aug 25, 2020 0
Most Valuable Participant ,
Aug 25, 2020

Copy link to clipboard

Copied

What should be the value of the field if it is not "YES"?

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...
Aug 25, 2020 0
New Here ,
Aug 25, 2020

Copy link to clipboard

Copied

nothing. . .they would either say YES to the In-state field to get that calculation. NO would do nothing.

 

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...
Aug 25, 2020 0
New Here ,
Aug 25, 2020

Copy link to clipboard

Copied

I guess it would be better to have the dropdown box be IN-STATE or OUT-OF-STATE, instead of YES/NO for each.

If I did that, IN-STATE would have the 20% calculation and OUT-OF-STATE would have the 30% calculation.

Hope that makes sense.

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...
Aug 25, 2020 0
Most Valuable Participant ,
Aug 25, 2020

Copy link to clipboard

Copied

You can use this code as the custom calculation script, then:

 

var v1 = this.getField("Field2").valueAsString;
var v2 = Number(this.getField("Field3").valueAsString);
if (v1 =="IN-STATE") event.value = v2 * 0.20;
else if (v1 =="OUT-OF-STATE") event.value = v2 * 0.30;
else event.value = "";

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...
Aug 25, 2020 0
New Here ,
Aug 25, 2020

Copy link to clipboard

Copied

Thank you so much!

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...
Aug 25, 2020 0