行,所以我需要修改它低於以能夠識別用戶是在哪個類別的代碼的分類是: 代碼修改,以確定類別中的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