Skip to main content
Participant
June 7, 2020
Question

Use checkbox to add sales tax

  • June 7, 2020
  • 1 reply
  • 615 views

Hi all!

I am trying to build a simple interactive form, but Javascript is evidently not to be learned in a few hours. I would appreciate any help you can offer.

 

I can isolate the issue as follows:

There are three fields: Text1, Text2, and Checkbox

Text1 contains an amount (e.g. $100.00)

Text2 is blank by default. 

When Checkbox is checked, it causes Text2 to populate with sales tax based on Text1 ($100.00) so would read $13.00.

I imagine the plain language formula for Text2 is "If Checkbox value = true then Text2 value = (Text1 * 0.13) else ""

but I have no idea how to actually implement this. 

 

Thanks so much in advance!

 

Chris

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
June 7, 2020

Add a custom calculatin script to Text2

 

if(this.getField("Checkbox").value != "Off")

    event.value = this.getField('Text1").value * 0.13;

 

You can read about exactly this type of conditional calculation and get a sample here:

https://acrobatusers.com/tutorials/conditional-execution/

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
June 8, 2020

Add this to the end of the code, or the value won't change after you un-tick the box:

else event.value = 0;