I am trying to write a program to calculate BMI. I would also like to have the script highlight the corresponding answer in my table. My math is not working correctly. The BMI calculation is putting out an incorrect answer even though the formula is correct.
I also cannot figure out how to highlight the text in the table.
<!DOCTYPE html>
<html>
<head>
<title>BMI Calculator</title>
<script type="text/javascript">
function calculateBMI(){
var Height = parseFloat(document.getElementById("Height").value);
var Weight = parseFloat(document.getElementById("Weight").value);
var Height;
var Weight;
BMI = ((Weight*703)/Height^2);
document.getElementById("BMI").value = BMI;
}
</script>
</head>
<body>
<h1>BMI Calculator</h1>
<p>To use, please input the height and weight and press calculate<p>
<form name="BMICalculator">
Height:
<input type = "text" id="Height" name="Height" value="" />inches<br />
Weight
<input type = "text" id="Weight" name="Weight" value="" />lbs<br />
<input type = "button" id="calculate" name="Calculate" value="Calculate" onclick="calculateBMI();" />
<input type = "reset" id="Reset" name="Reset" value="Reset" /><br />
<br>
BMI:
<input type = "text" id="BMI" name="BMI" value="" /><br />
</form>
<br>
<table style="width:100%", border="1px solid black">
<tr>
<td>Underweight</td>
<td><18.5</td>
</tr>
<tr>
<td>Normal weight</td>
<td>18.5 - 24.9</td>
</tr>
<tr>
<td>Overweight</td>
<td>25 - 29.9</td>
</tr>
<tr>
<td>Obesity</td>
<td>30 or more</td>
</tr>
</table>
</body>
</html>