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

Need javascript to calculate a percentage

New Here ,
Jan 22, 2019 Jan 22, 2019

Copy link to clipboard

Copied

Any help would be greatly appreciated. I need a java script to get the percentage of 2 numbers. I am including a picture below. For example, I need the number for Conventional Conforming divided by the Total to get the percentage used. Can anyone help?

TOPICS
Acrobat SDK and JavaScript

Views

201

Likes

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

correct answers 1 Correct answer

Community Expert , Jan 22, 2019 Jan 22, 2019

Sorry, didn't realize they were the same fields...

You can use this code as the custom calculation script of the percentage field, then:

var v1 = Number(this.getField("1cc").valueAsString);

var v2 = Number(this.getField("totalvolume").valueAsString);

if (v2==0) event.value = "";

else event.value = v1/v2;

Likes

Translate

Translate
Community Expert ,
Jan 22, 2019 Jan 22, 2019

Copy link to clipboard

Copied

What are the names of the fields involved?

Likes

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
New Here ,
Jan 22, 2019 Jan 22, 2019

Copy link to clipboard

Copied

Likes

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 ,
Jan 22, 2019 Jan 22, 2019

Copy link to clipboard

Copied

Sorry, didn't realize they were the same fields...

You can use this code as the custom calculation script of the percentage field, then:

var v1 = Number(this.getField("1cc").valueAsString);

var v2 = Number(this.getField("totalvolume").valueAsString);

if (v2==0) event.value = "";

else event.value = v1/v2;

Likes

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
New Here ,
Jan 22, 2019 Jan 22, 2019

Copy link to clipboard

Copied

LATEST

You are a lifesaver!! Thank you so much!

Likes

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