Skip to main content
Participant
July 25, 2023
Question

Wanting to add a age block into the calculation for body fat

  • July 25, 2023
  • 2 replies
  • 841 views

I found the following java script and it works. But i would like to add the use of Age into the calculation for body fat. Not sure if it can be done with out a major overhaul of the script. But figured it wouldnt hurt to reach out and see. Also, this is on a form that we use for work and I am trying to make it better. It would make our basic pre qualification process much easier to have the body fat calculation ahead of time.

 

The following is the script that works but does not have age involved. I feel like it could be more accurate with age involved in it.

 

(function () {

 

    // Get the field values, as text

    var weight = +getField("E7. a. 2. Weight").value;

    var feet = +getField("E7. a. 1. Height").value;

    var inches = +getField("E7. a. 1. Feet").value;

    var height = (feet * 12) + inches;

 

    // Perform the calculation if both values are greater than zero

    if (weight > 0 && height > 0) {

        event.value = 703 * weight / Math.pow(height, 2);

    } else {

        event.value = "";  // Blank this field

    }

 

})();

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
July 26, 2023

It's certainly possible. If you specify the logic we could help with the code...

Participant
August 1, 2023

I'm a recruiter and it would make prescreening applicants a little easier and more accurate if we could calculate body fat based on height, weight and age. We also do the tape test for people that are over the weight standard for their age. 

Thom Parker
Community Expert
Community Expert
July 26, 2023

What's stopping you?

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
August 1, 2023

Probably my lack of experience with the codes and formulas needed for the calculations. 

try67
Community Expert
Community Expert
August 1, 2023
We can help with the codes, if you provide the formulas.