Need a script to complete this form...

New Here ,
Dec 26, 2019

Copy link to clipboard

Copied

Is there an existing script that will auto-calculate "B" and "C" when keying in a number value for "A", based on "D" OR "E"? (see attached) Any help would be greatly appreciated. Thanks in advance.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Multiply the result by the item price.

TOPICS
Acrobat SDK and JavaScript

Views

128

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

Need a script to complete this form...

New Here ,
Dec 26, 2019

Copy link to clipboard

Copied

Is there an existing script that will auto-calculate "B" and "C" when keying in a number value for "A", based on "D" OR "E"? (see attached) Any help would be greatly appreciated. Thanks in advance.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Multiply the result by the item price.

TOPICS
Acrobat SDK and JavaScript

Views

129

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
Dec 26, 2019 0
Most Valuable Participant ,
Dec 27, 2019

Copy link to clipboard

Copied

A script could certainly be written. You won't find that scripts just exist already, there are countless trillions of possible needs. Many of us see our task here as helping to learn to write your own scripts. Do you have any coding experience already?

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...
Dec 27, 2019 0
Most Valuable Participant ,
Dec 27, 2019

Copy link to clipboard

Copied

This is certainly possible, but you need to better explain how it should work.

Is the number in A free for you the user to enter? What should happen if they enter 54, for example?

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...
Dec 27, 2019 0
New Here ,
Dec 31, 2019

Copy link to clipboard

Copied

Thanks for the response try67. If it’s possible to populate the FREE field that would be great, but I don’t believe it’s necessary.  My understanding for the BUY 11, Get 1 Free and BUY 100, GET 20 Free is that partial orders do not receive FREE QTY.   If they enter 54 for the Buy 11 Get 1 FREE it would be 4 Free since they would have to purchase 55 to obtain 5 FREE.  The Net GSP price/unit remains the same.

 

11-21, get 1 free

22-32, get 2 free

33-43, get 3 free … and so on.

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...
Dec 31, 2019 0
Most Valuable Participant ,
Dec 31, 2019

Copy link to clipboard

Copied

You can use this code as the custom calculation script of the "Free Qty" field:

 

var totalItems = Number(this.getField("Qty").valueAsString);
var freeItems = Math.floor(totalItems/100);
totalItems -= freeItems*100;
freeItems += Math.floor(totalItems/11);
event.value = freeItems;

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...
Dec 31, 2019 0
New Here ,
Dec 31, 2019

Copy link to clipboard

Copied

That's awesome, thank you. But how do i get the subtotal to calculate based on the quantity selected with the 3 different price points?

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...
Dec 31, 2019 0
Most Valuable Participant ,
Jan 01, 2020

Copy link to clipboard

Copied

Multiply the result by the item price.

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...
Jan 01, 2020 0
New Here ,
Jan 07, 2020

Copy link to clipboard

Copied

Thank you so much. This worked out great. Much appreciated.

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...
Jan 07, 2020 0