行,所以我需要修改它低于以能够识别用户是在哪个类别的代码的分类是: 代码修改,以确定类别中的HTML代码
- 小于18.5体重不足
- 18.5至25正常
- 25-30超重
- 超过30肥胖
,然后在结束我需要的代码automaticall y知道用户在什么类别并显示:这意味着你是(低体重,正常等)
谢谢。
<html>
<head>
<title>BMI Calculator</title>
<script type="text/javascript">
function computeBMI()
{
//Obtain user inputs
var height=Number(document.getElementById("height").value);
varheightunits=document.getElementById("heightunits").value;
var weight=Number(document.getElementById("weight").value);
varweightunits=document.getElementById("weightunits").value;
//Convert all units to metric
if (heightunits=="inches") height/=39.3700787;
if (weightunits=="lb") weight/=2.20462;
//Perform calculation
var BMI=weight/Math.pow(height,2);
//Display result of calculation
document.getElementById("output").innerText=Math.round(BMI*100)/100;
}
</script>
</head>
<body>
<h1>Body Mass Index Calculator</h1>
<p>Enter your height: <input type="text" id="height"/>
<select type="multiple" id="heightunits">
<option value="metres" selected="selected">metres</option>
<option value="inches">inches</option>
</select>
</p>
<p>Enter your weight: <input type="text" id="weight"/>
<select type="multiple" id="weightunits">
<option value="kg" selected="selected">kilograms</option>
<option value="lb">pounds</option>
</select>
</p>
<input type="submit" value="computeBMI" onclick="computeBMI();">
<h1>Your BMI is: <span id="output">?</span></h1>
</body>
</html>
为什么我觉得我做的某人的学校作业? – Schien
哈哈,那么,你是:P – witherwind
好吧,有一些语法错误...'varheightunits'可能是'var heightunits' – helderdarocha