Copy link to clipboard
Copied
Hi All,
Not sure how to search for this question so I'm just going to ask it in a new thread. Please point me to an existing thread if it exists.
I have a form with 2 line items, each with a qty field:
Parts: ($ amount) Qty:
Labour: ($ amount) Qty:
eg
Parts: $100 Qty: 2
Labour: $200 Qty: 1
TOTAL: $400
I am able to calculate the parts and labour with the use of hidden helper fields with Adobe Acrobats calculations feature via the Calculate Tab in the Text Field Properties box for each field, so the above example would calculate to $400.
What I can't work out is the user wants 2 radio buttons. 1. GST Inclusive 2. No GST. This is in Australia so GST of 10% gets added to the total if the GST Inclusive button is ticked (above eg would come to $440). If the No GST button is ticked, it's just the normal sum total of Parts & Labour (above eg $400).
Can someone point me to the right direction of writing some javascript to show the TOTAL field with ($440) or without GST ($400), depending on which radio button is ticked?
Hidden Helper cells (if this helps) are:
- PartsTotal (Parts x PartsQty = $200)
- LabourTotal (Labour x LabourQty = $200)
- GST_10pc (0.1)
- TOTAL_NoGST (PartsTotal + Labour Total = $400)
- TOTAL_GST_Calc (TOTAL_NoGST x GST_10pc = $40)
- TOTAL_wGST (TOTAL_NoGST + TOTAL_GST_Calc = $440)
I have no problem with the helper cells calculating the $400 and $440 totals (above) but I don't know how to show either field in the TOTAL Field so that TOTAL shows the contents of either TOTAL_NoGST or TOTAL_wGST.
In other words an if statement would read:
If
GST Inc is ticked, show TOTAL_wGST in TOTAL
else
if
No GST is ticked, show TOTAL_NoGST in TOTAL
else
Show a blank field until one of them is ticked (would be a nice addition to the javascript if possible, or I could just make the radio buttons compulsory)
Hope that's clear.
Thanks
Copy link to clipboard
Copied
Mozilla Developer Network has poste for free the JavaScript Reference This provides the common core JavaScript statements and Adobe has posted for free the Acrobat JavaScript Reference which has the objects that are unique to Acrobat.
Copy link to clipboard
Copied
Thanks @gkaiseril. I was more asking if anyone knew some sample code which I could play with to fit my scenario. I'm not fluent in Javascript but can find my way around it if shown some code.
I will read through those references and see if I can work something out.
Thanks again.
Copy link to clipboard
Copied
How to do (not so simple) form calculations by Thom Parker
Find more inspiration, events, and resources on the new Adobe Community
Explore Now