Body Fat Calculator

If you have a web site that deals with health or diet then here is a body fat calculator that may make a good addition to your site. The following body fat calculator uses the U.S. Navy Circumference Method where three or four body measurements are fed into a fixed formula to estimate the percentage of your body that is made up of fat. The measurements need to be accurate to within 0.5cm or 0.25 inches and should be taken as follows:

The first thing to note with this calculator is that it has a PHP fallback built in so that the calculator will still work even for those visitors who have JavaScript disabled. In addition the script is designed to be reasonably unobtrusive. None of the JavaScript is in global scope except for the submit event on the form and the id values chosen are ones that are hopefully very unlikely to appear elsewhere in your page. If for some reason one or more of the ids do clash then simply change every reference to that id to a different value to resolve the clash.

To install the calculator on your own site first download and unzip the files. You can then modify the bfat.php file that contains the form to add whatever other content that you want to appear on the same page or if you prefer you can copy and paste the various parts of that page into the page where you want to install the calculator.

Most of the code is needed to validate the values that your visitor enters into the form in order to make sure that the values are numeric and within a reasonable range. The actual calculations themselves (if you are interested in what those formula actually are) can be found in the maleFat() and femaleFat() functions.

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate