|
Appending javascript to weight/height to meters and kikograms
I have this working figuring BMI in lbs and Inches. I need to incorporate a prompt box asking S for Standard and M for Metric, IF S is selected then it will perform calculation as follows: bmi=weight * 703/ (height * height), If M is chosen then calculation will be: bmi=weight/(height * height) Here is what I have so far:
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtlm1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
/*<![cdata[*/
//state the variable
var weight=prompt("Please enter your weight in lbs.");
var height=prompt("Please enter your height in inches");
var BMI = weight *703/(height * height);
weight = parseInt(weight);
height = parseInt(height);
if (BMI <18.5)
{
document.write("Your are Underweight for your Height and Weight");
}
else if (BMI <= 24.9)
{
document.write ("<p> You are of Normal Weight for your Height and Weight</p>");
}
else if (BMI <= 29.9)
{
document.write ("<p> You are overweight for your Height and Weight</p>");
}
else if (BMI >=30)
{
document.write ("<p> You are considered Obese for your Height and Weight</p>");
}
/*]]>*/
</script>
</head>
<body>
</body>
</html>
|