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

Java script calculation

New Here ,
Mar 22, 2017 Mar 22, 2017

I'm creating a form and I need the code to calculate 6% tax to the price total (field)? Please advice, thank you in advance!

TOPICS
Acrobat SDK and JavaScript
481
Translate
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 ,
Mar 23, 2017 Mar 23, 2017

Get the field's value and then multiply it by 0.06 ...

Translate
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
New Here ,
Mar 23, 2017 Mar 23, 2017

But how do I code this formula?

Translate
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 ,
Mar 23, 2017 Mar 23, 2017

Do you want to apply the value to a different field, or just use it in your code for something else?

Translate
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
New Here ,
Mar 23, 2017 Mar 23, 2017

Yes I want the value ( the amount of the multiplication) to reflect on the field.

I guess I word it wrong I want to do a multiplication on the tax field for the taxes.

Translate
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
New Here ,
Mar 23, 2017 Mar 23, 2017

I WANT TO MULTIPLY FIELD NAME: SUB TOTAL

THE FORMULA IS SUPPOSED TO BE: SUB TOTAL * 0.06

AND THE ANSWER TO BE REFLECTED ON THE FIELD NAME: PRICE TAXES

I DON'T KNOW HOW TO CODE IT?

Translate
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 ,
Mar 23, 2017 Mar 23, 2017

If you use the simplified field notation option, you could use the folowing

0.06 * SUB\ TOTAL

If the field name didn't have a space in it and were instead "SUBTOTAL", it would be:

0.06 * SUBTOTAL

If you want to use a custom JavaScript option, the calculation script could be:

// Custom calculation script in PRICE TAXES field

(function () {

    // Get the field value, as a number

    var v = +getField("SUB TOTAL").value;

    // Calculate, round to two decimals, and set this field value

    event.value = util.printf("%.2f", 0.06 * v);

})();

When you're done setting up the calculated fields, make sure the field calculation order is correct for the form.

Translate
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
New Here ,
Mar 23, 2017 Mar 23, 2017
LATEST

IT WORKED THANK YOU SO MUCH!!!!

Translate
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