View Single Post
Old 11-10-2012, 09:48 PM   PM User | #5
axel22
New to the CF scene

 
Join Date: Oct 2012
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
axel22 is an unknown quantity at this point
Code:
<html>
<head>
<title> BodyFat Formula </title>
<script type="text/javascript">
function BodyFat(weight, waist, bodyfat){


var weight = parseInt(document.getElementById("weightBox").value, 10);
var waist = parseInt(document.getElementById("waistBox").value, 10);
var BodyFat = parseInt(document.getElementById("bodyfatBox").value, 10);
	
	weightBox = Math.round(weight * 1.082) + (94.42);
	waistBox = Math.round(waist * 4.15);

var str1="Your Body Fat Percentage is ";
document.getElementById('outputDiv').innerHTML= str1.concat(weight);

}
</script>
</head>
<h2>BodyFat Formula</h2>
<p>
    Weight: <input type="number" id="weightBox" size="4" value="150" min="0"> pounds
 <br>
    Waist measurement: <input type="number" id="waistBox" size="4" value="32" min="0"> inches
<br>
    BodyFat: <input type="number" id="bodyfatBox" size="4" value="0" min="0" max="0"> percent
<br>
</p>
<input type="button" value="Calculate body fat" onclick="BodyFat();">
<hr>
<div id="outputDiv"></div>
</html>
How is that? Im just confused now it just shows the weight as an answer not the equation?
axel22 is offline   Reply With Quote