Formula for multiplcation and conditional limit on Adobe PDF form

New Here ,
Apr 06, 2016

Copy link to clipboard

Copied

Hello, I am working on an Adobe PDF Form and believe I need a custom script for a calculation table. I have no JavaScript experience at the moment and am hoping someone can help me with a formula so I can complete a project. We have a table in a form that is supposed to calculate a discount. The field for the formula in question is a rebate field with a maximum value of $4,000. The field calculates the # of blocks multiplied by $1,000 with a maximum rebate of $4,000. How do I write a formula that returns the rebate amount if it is less than $4,000 (e.g. $1,000, $2,000 or $3,000) and only displays $4,000 if the rebate amount is equal to or greater than $4,000? I hope this is understandable and please forgive my ignorance. Thanks!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Let's say the other field is called "Rebate". Use this code as the custom calculation script of the Discount field:

event.value = Math.min(4000, Number(this.getField("Rebate").value));

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

338

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

Formula for multiplcation and conditional limit on Adobe PDF form

New Here ,
Apr 06, 2016

Copy link to clipboard

Copied

Hello, I am working on an Adobe PDF Form and believe I need a custom script for a calculation table. I have no JavaScript experience at the moment and am hoping someone can help me with a formula so I can complete a project. We have a table in a form that is supposed to calculate a discount. The field for the formula in question is a rebate field with a maximum value of $4,000. The field calculates the # of blocks multiplied by $1,000 with a maximum rebate of $4,000. How do I write a formula that returns the rebate amount if it is less than $4,000 (e.g. $1,000, $2,000 or $3,000) and only displays $4,000 if the rebate amount is equal to or greater than $4,000? I hope this is understandable and please forgive my ignorance. Thanks!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Let's say the other field is called "Rebate". Use this code as the custom calculation script of the Discount field:

event.value = Math.min(4000, Number(this.getField("Rebate").value));

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

339

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
Apr 06, 2016 0
Most Valuable Participant ,
Apr 06, 2016

Copy link to clipboard

Copied

Let's say the other field is called "Rebate". Use this code as the custom calculation script of the Discount field:

event.value = Math.min(4000, Number(this.getField("Rebate").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...
Apr 06, 2016 0
New Here ,
Apr 06, 2016

Copy link to clipboard

Copied

Thank you - that worked like a charm!

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...
Apr 06, 2016 0
New Here ,
May 19, 2020

Copy link to clipboard

Copied

Hello Try67, I hope you dont mind me jumping on this thread I have a similar calculation but couldnt quiet work it out from your answer above- I am fairly new to adobe and communities. I have a form where people fill out how much of each product they would like and at the end need to calculate a delivery fee for order under $100 being $10. Order over $100 will get free delivery. Are you able to help or should I post this as a new thread? Thanks heaps Sarah

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...
May 19, 2020 0
Adobe Community Professional ,
May 20, 2020

Copy link to clipboard

Copied

New Thread.

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...
May 20, 2020 0