• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how to add gst calculation based on selection from radio button

Community Beginner ,
Sep 30, 2019 Sep 30, 2019

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.

 

clipboard_image_0.png

TOPICS
Acrobat SDK and JavaScript

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Sep 30, 2019 Sep 30, 2019

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 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

It is a fill in pdf form

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

Thank you for bringing this up. I just changed URL to a different discussion.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 30, 2019 Sep 30, 2019

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

It should be mutually exclusive, the user should be able to choose only one option from the 3 ( GST Exc, GST Incl, GST Free)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 30, 2019 Sep 30, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 01, 2019 Oct 01, 2019

Copy link to clipboard

Copied

NaN means something quite specific (it is well defined as the result of several impossible mathematical formula, never random) and you can eliminate it almost completely by always checking every value you divide by, to make sure it is not zero. (Other math operations can return NaN, but they are rarer e,g, Math.sqrt(-1).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2019 Oct 03, 2019

Copy link to clipboard

Copied

Thank you. It took me a while to understand what you meant. The answer was all along right in front of me.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2019 Oct 03, 2019

Copy link to clipboard

Copied

LATEST

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines