Skip to main content
Participant
July 14, 2021
Answered

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

  • July 14, 2021
  • 2 replies
  • 6254 views

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!

This topic has been closed for replies.
Correct answer try67

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.

2 replies

Thom Parker
Community Expert
Community Expert
January 12, 2022
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
July 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.

Participant
July 14, 2021

Thanks!!

This is exactly what I needed.

Participating Frequently
January 11, 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?