Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

How to calculate the value of a field based on another field

New Here ,
Jul 14, 2021 Jul 14, 2021

I am creating a fairly basic registration form. Users can select multiple sessions throughout the week. What I need to do is allow them to select their sessions, and then have the form display the total cost. In Excel I can have the users enter an "X" in the appropriate cell, then create another cell that says "if A1 = "X", then A2 = $500. I then hide A2 and have another cell display the total of A2, B2, C2, etc. 

In Adobe, it seems that I can have a text field with the value of $500 for each session which the user can select, and then have a total field that addes up all the session fields to display the total cost. This works, but is not pretty to look at. It would be better/nicer to have a check box for each session and then have a total field that displayed the amount based on the number of check boxes that were checked.

It seems like this is something that has been done before, but I can't find a good solution. Any and all help is appreciated!

TOPICS
How to , PDF forms
6.0K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Jul 14, 2021 Jul 14, 2021

It's very easily done, and you don't need to use hidden text fields for the amounts.

Just set the export value of each check-box to the corresponding amount and then use the built-in Sum option under the Calculate tab of your total text field to add the values of all the fields. Only those that are ticked will be included in the sum.

View solution in original post

Translate
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 Expert ,
Jul 14, 2021 Jul 14, 2021

It's very easily done, and you don't need to use hidden text fields for the amounts.

Just set the export value of each check-box to the corresponding amount and then use the built-in Sum option under the Calculate tab of your total text field to add the values of all the fields. Only those that are ticked will be included in the sum.

Translate
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
New Here ,
Jul 14, 2021 Jul 14, 2021

Thanks!!

This is exactly what I needed.

Translate
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
New Here ,
Jan 10, 2022 Jan 10, 2022

Hi,

I'm trying to do something similar. I have an order form that has drop downs with export values of how much each item costs. Then I added a text field that calculates the sum of all dropdown items. However, it is adding the export values + the text that is listed on the front end. How can I fix that?

Translate
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 Expert ,
Jan 11, 2022 Jan 11, 2022

That's odd. Can you share the file in question?

Translate
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
New Here ,
Jan 11, 2022 Jan 11, 2022

Sure. Thanks so much!

Translate
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
New Here ,
Jan 11, 2022 Jan 11, 2022

I updated the first item to export at 96.00. Try selecting any amount and the totals are calculated by the Appetizers header.

Translate
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
New Here ,
Jan 12, 2022 Jan 12, 2022

Sorry to bother again, were you able to download the form?

Translate
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 Expert ,
Jan 12, 2022 Jan 12, 2022

Yes. Your calculation formula on the drop-downs is incorrect. This is not a valid formula:

=*96

The way to do it is to use a custom calculation script on the total field to multiple the value of each field with the price. That price can be hard-coded into the script, or it can come from another text field, which can be hidden.

 

Translate
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
New Here ,
Jan 12, 2022 Jan 12, 2022

Thanks so much!

Translate
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 Expert ,
Jan 12, 2022 Jan 12, 2022
LATEST

Read this article:

https://www.pdfscripting.com/public/How-to-Write-a-Basic-PDF-Calculation-Script.cfm

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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