Skip to main content
Participant
May 14, 2021
Answered

Need to calculate a percentage in fillable pdf and can't get the code right

  • May 14, 2021
  • 2 replies
  • 1014 views

I'm creating a worksheet meant to help with budgeting, adding up expenses and calculated a percentage based off of a number that is the total of two salary inputs. 

One of the fields is meant to calculate %50 percent of the total salary. 

 

Here's the code I'm using:

var Salary_Total = getField("Salary_Total").value;

var percentToGet = 0.50;

var percent = (percentToGet / 100) * number;

event.value = Salary_Total * Percentage;

 

What am I doing wrong here?

This topic has been closed for replies.
Correct answer try67

So you just want it to show 50% of the value of Salary_Total?

If so, just enter this under the Simplified Field Notation option in the Calculate tab:
Salary_Total * 0.5

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
May 14, 2021

So you just want it to show 50% of the value of Salary_Total?

If so, just enter this under the Simplified Field Notation option in the Calculate tab:
Salary_Total * 0.5

Participant
May 14, 2021

That is exactly what I want to do and it worked. Thank you!

try67
Community Expert
Community Expert
May 14, 2021

Where's the definition of the "number" variable?

Participant
May 14, 2021

I guess I don't have anything there that it defines, I just copy/pasted from another forum trying to figure it out myself. I'm sorry, I have absolutely zero knowledge of javascript and was rushed into this project. Everything I've set up so far is from googling.