Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Generate calculations based on variables for a contract?

Community Beginner ,
Jul 06, 2021 Jul 06, 2021

Copy link to clipboard

Copied

Hello,

 

My goal is to create a fillable contract through Adobe Acrobat that can calculate costs based on hidden variables. For example if someone selected 50 united inches from a dropdown, there is a variable in the backround saying it's $1 per 1 united inch, so that is $50 for 50 united inches and spits that out into the total cost. Is there a way to do this?

 

I hope this makes sense.

TOPICS
Comment review and collaborate PDF, Create PDFs, General troubleshooting, How to, PDF forms

Views

52

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
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Jul 07, 2021 Jul 07, 2021
After thinking a little more about this, anohter thing you can do is to add an "export value" to your dropdown value items: A dropdown control can have two different sets of values associated with it: The display values, and the corresponding export value. The display value would be what you want your users to see, and the export value would be the unit price. So let's say you have a control that is named "product", and a second field named "amount", and a third field called "lineTotal", you cou...

Likes

Translate

Translate
Adobe Community Professional ,
Jul 06, 2021 Jul 06, 2021

Copy link to clipboard

Copied

Yes, you can do that. The best way to add complexer logic to a form is by using JavaScript in your form. You would create some JavaScript code that would get triggered by the user changing a field. A custom calculation script associated with your "Total" field can do that. This does add quite a bit of complexity (and the associated learning curve) to your project. There are a lot of online resources availabe to learn how to do that. You can explore these features on the Adobe web site, but if you want to get serious about using JavaScript, I recommend that you subscribe to the PDFScripting.com web site (unfortunately this is not free, but there is a huge amount of very useful information available, and no, I do not have an affiliation with the site). To learn JavaScript, take a look here: http://khkonsulting.com/2017/01/learning-to-program-javascript-for-adobe-acrobat/

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
community guidelines
Community Beginner ,
Jul 07, 2021 Jul 07, 2021

Copy link to clipboard

Copied

I am willing to learn JavaScript as it seems to be a useful tool all across Adobe and Microsoft platforms. Of course, I know this may take me a while to learn it. Do you know of anyone who would be willing to assist me with creating the general structure of the script and then I could use that as a guide to continue the script? 

 

Thank you for the resources you provided.

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
community guidelines
Adobe Community Professional ,
Jul 07, 2021 Jul 07, 2021

Copy link to clipboard

Copied

After thinking a little more about this, anohter thing you can do is to add an "export value" to your dropdown value items: A dropdown control can have two different sets of values associated with it: The display values, and the corresponding export value. The display value would be what you want your users to see, and the export value would be the unit price. So let's say you have a control that is named "product", and a second field named "amount", and a third field called "lineTotal", you could configure the 'lineTotal" field to calculate the product of the hidden export value and the amount. This can be done using any of the calculation methods on the "Calcuate" tab. For the simple method, you just select to create a product, and then select the two related fields. For the simple field notation, you would enter the following:

amount * product

And I'll leave out the JavaScript for now 🙂 

 

If you have multipe lines, you can then also add a final "total" field at the end that is the sum of all the line totals. For this, you would need to create a naming schema that allows you to add a line number to your field names (e.g. amount.1 and product.1 will result in lineTotal.1, amount.2 and product.2 will result in lineTotal.2 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
community guidelines
Community Beginner ,
Jul 09, 2021 Jul 09, 2021

Copy link to clipboard

Copied

LATEST

Thank you Karl, I will try out this method first once I construct everything and see how it goes.  I appreciate your thought out response.

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
community guidelines