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

Ratio Calculation?

New Here ,
Oct 03, 2022 Oct 03, 2022

Copy link to clipboard

Copied

Hi everyone! I'm a beginner and don't know anything about writing code. I am trying to create a form for work and want the last box (Text 3.4) to show as a percentage. The formula that I want this form to calculate is [(Text 3.2 + Text 3.3)/ (Text 3.0 + Text 3.1)] * 100%. Can anyone please help me? It would be so greatly appreciated. Thank you!

 

Adobe question.png

TOPICS
Acrobat SDK and JavaScript

Views

29

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

New Here , Oct 03, 2022 Oct 03, 2022

I could literally cry, I am so happy. After hours of searching and learning, I figured it out! In case anyone else needs help in the future, this was the code I used 🙂 btw I changed the names so Staff1=Text3.0, Student1=Text3.1, Staff2=Text3.2, Student2=Text3.3.

 

var v1 = Number(this.getField("Staff1").valueAsString);
var v2 = Number(this.getField("Student1").valueAsString);
var v3 = Number(this.getField("Staff2").valueAsString);
var v4 = Number(this.getField("Student2").valueAsString);
if (v2==0) e

...

Likes

Translate

Translate
New Here ,
Oct 03, 2022 Oct 03, 2022

Copy link to clipboard

Copied

LATEST

I could literally cry, I am so happy. After hours of searching and learning, I figured it out! In case anyone else needs help in the future, this was the code I used 🙂 btw I changed the names so Staff1=Text3.0, Student1=Text3.1, Staff2=Text3.2, Student2=Text3.3.

 

var v1 = Number(this.getField("Staff1").valueAsString);
var v2 = Number(this.getField("Student1").valueAsString);
var v3 = Number(this.getField("Staff2").valueAsString);
var v4 = Number(this.getField("Student2").valueAsString);
if (v2==0) event.value = "";
else event.value = Math.round((((v3+v4)/(v1+v2))*100));

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