Skip to main content
Participant
May 14, 2021 9:27 PM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
May 14, 2021 9:56 PM UTC

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

4 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
May 14, 2021 9:56 PM UTC

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

Translate
Participant
May 14, 2021 9:59 PM UTC

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

Translate
try67
Community Expert
Community Expert
May 14, 2021 9:32 PM UTC

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

Translate
Participant
May 14, 2021 9:44 PM UTC

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.

Translate