Copy link to clipboard
Copied
I need assistance to write a script for my GST calculation based on the selection of radio button:
GST Excl (radio button) is selected - 10% must be added over the subtotal
GST Free )radio button is selected - no gst is calculated
GST Incl (radio button ) is selected - subtotal must be divided by 11 (i am almost giving up my hopes as this may be too ambitious) .
I have learned adobe all by myself but just stuck on this form for ages.
Copy link to clipboard
Copied
Hello,
Is this PDF (form or file) that you have to write calculation for?
Here is an existing discussion: https://community.adobe.com/t5/Acrobat/Override-Calculation-Based-on-Radio-Button-Value/td-p/9063667 let us know if that helps.
Note: Response edited
-Tariq
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi Tariq Dar
"https://community.adobe.com/t5/Acrobat-archive/calculating-radio-buttons/td-p/9796914"
This URL returns Access denied.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi,
Just curious about your post... shouldn't the radio buttons be used in pairs or in groups to work effectively? Is the user able to choose more than one option (like Inclusive and Exclusive altogether) or just one action?
Maybe using a check box is better suited for the operations that you are wrestling with.
And what is the subtotal calculated with ? Is that field a manual entry for the user or are the subtotal is calculated with the information provided in other fields?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I see what you are saying when you mentioned that you've spent ages on this.
Since I read your post, I've been challenged trying to recreate the scenario.
Just when you think you are getting it to work then I get stuck with the infamous "NaN" .
Do you know any weight-lifters? you know... those individuals who eat the weights at the gym everyday like in beast mode? Well, that is how my brain feels right now...
There is no way to quantify how much mass my brain has gained in the past 4 hours trying to work around this form.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
After seriously understanding the thred posted by Tariq Dar. I had to consult with another thread to come up with a simplified solution.
So, I came up with this:
When you create the radio button all of them will be labeled with the same name. In this case I named my three radio buttons "GST".
However, in order to be able to have each radio button yo act independently from each other when it is clicked on by the user, I had to assign an export value where it says "Radio Button Choice" under the "Options" Tab.
In my form it is listed like this:
radio button1 = 11 (to express the GST Inclusive export value of this field )
radio button 2 = 10 (to express the GST Exclusive export value of this field )
radio button 3 = 1 (I left blank or assign a number 1; my issue was using 0 here before, therefore the "NaN" poping up and other intimidating and discouraging errors that almost made me quit this exercise)
(No event.Will.commit javascript was necessary in the radio buttons for this to work; it was so simple after figuring this out)
So, the text fields I named them like this:
SubTotal (this field is a manual text entry no script needed)
GSTCalc (and this is the custom calculation scriptfor this field):
var a = this.getField("SubTotal").value;
var b = this.getField("GSTCALC").value;
var c = this.getField("GST").value;
if (c=="11") event.value = a/c;
else if(c=="10") event.value = a/c;
else if(c=="1") event.value = "";
TotalValue (and here just use Simplified Notattion to add SubTotal and GSTCalc)
Hope this helps.