In this tutorial, learn how to create a hidden form field in a fillable PDF form that keeps the field hidden from your recipients. Suppose you're working on a PDF form, and you want to calculate a surcharge or tax to add to a total, but you don't want users trying to type into the field. In this quick tip, learn how you can take care of the problem by hiding the field in the PDF form. The next time you need to calculate something in your PDF form using a constant value, try using a hidden field.
Donna Baker – February 6, 2012
Suppose you're working on a PDF form, and you want to calculate a surcharge or tax to add to a total, but you don't want users trying to type into the field. You can take care of the problem by hiding the field in the PDF form.
A typical order form often uses a hidden field to calculate sales tax. Each product row has fields to enter costs and amounts to produce row totals. Then there's a subtotal field that adds up all the product lines.
Now comes the hidden field to provide the amount of tax, which is also a regular text field with a couple of extras. Double-click the field to open its properties. On the General tab, click the Form Field drop-down arrow and choose Hidden. If you plan to print your form, you might want to choose Hidden but Printable instead so you can see the value used in the calculation.
You don't need a tooltip as your user won't see the field anyway. For the same reason, you don't need to select anything on the Appearance tab. In the Options tab, type the default value you want Acrobat to use for calculating, such as .07 for a 7% tax. Then click the Format tab and pick Numbers from the drop-down list. To use a percentage expressed as a decimal value, leave the default 2 decimal places.
Now your field has a set value to use for other calculations. For example, to calculate a 7% tax for a product order, open the dialog box for the visible Sales Tax field. On the Calculate tab, multiply the subtotal by the Tax field to produce the value shown for the sales tax.
The next time you need to calculate something in your form using a constant value, try using a hidden field.
Products covered: |
Acrobat XIAcrobat X |
Related topics: |
PDF Forms |
Top Searches: |
Convert existing forms to fillable PDFs, fill and sign any form |
6 comments
Comments for this tutorial are now closed.
Lori Kassuba
10, 2014-12-11 11, 2014Hi Max,
I agree about the use of this particular hidden field and I’ll pass along your comment to Donna.
Thanks,
Lori
Max Wyss
1, 2014-12-10 10, 2014@Lori @Don: Actually, there is a good idea to use a hidden field.
HOWEVER, this hidden field is used simply as an anchor to contain a Calculate script, in which it even does not participate. This Calculate script will contain the complete calculation of the form, and (with some exceptions) it is the ONLY field with a calculation. This has several great advantages:
• Full control over the calculations, and their dependencies. With only one field in the Calculation order, there is no more mess-up with calculation order. You set the calculation order in the script, where the flow of calculations is clear and natural.
• Only valid results. Calculations can create results. However, these results may not be valid, because, for example, not all input values are given (and replaced with 0 in JavaScript). Probably the very first issue an user may encounter is a division by zero. Having all together in one script allows to test for completeness (and range) of input values, and only do the calculation when the test succeeds.
• Performance. The way the field event processing is implemented, it allows for the procedure described here. But it can also be the cause of performance issues. Whenever something changes in a field, a sequence of events occurs, one of them the Calculate event. This event executes all calculations attached to fields, in the calculation order. If as a consequence of the calculation another field contents gets changed, that sequence runs again, and again…and again, the more fields with calculations you have.
So, yes, using a hidden field makes sense. But, sorry to say it, not in the way described in this tip.
Lori Kassuba
10, 2014-12-04 04, 2014Hi Don,
You don’t need to make it a hidden field - you could just use a custom calculation script as detailed here and then make the field read-only:
https://answers.acrobatusers.com/Create-java-scripts-sales-tax-6-q92018.aspx
Thanks,
Lori
Don
10, 2014-12-01 01, 2014Is using a hidden field preferable to putting the calculation all in the Sales tax box?
Lori Kassuba
8, 2014-08-19 19, 2014Hi Jennifer Purucker-Lander,
Have you tried using the Set Field Calculation Order command?
Thanks,
Lori
Jennifer Purucker-Lander
8, 2014-08-18 18, 2014MY SALES TAX IS NOT CALCULATING EITHER CAN YOU HELP ME PLEASE, I HAVE TRIED CODING JAVASCRIPT FROM THINGS I FOUND ONLINE AND THAT ISN’T WORKING EITHER IM DESPERATE FOR HELP
Lori Kassuba
2, 2014-02-24 24, 2014Hi Janet Lord,
Try making the field visible and setting the Calculation Order, testing it, and then making it hidden once everything works.
Thanks,
Lori
Janet Lord
9, 2014-02-17 17, 2014I have the same problem—sales tax is not calculating. Instruction to use Set Field Calculation Order was not helpful as it it did not show my hidden box containing the tax rate. Everything else is set as you describe in the video.
Lori Kassuba
3, 2013-10-14 14, 2013Hi Marie Lauer,
Try using the Set Field Calculation Order command to make sure this is occurring when the subtotal is calculated.
Thanks,
Lori
Marie Lauer
9, 2013-10-10 10, 2013I am trying to follow these instructions, but the sales tax % is not calculating. Any ideas why?
Comments for this tutorial are now closed.