大家好,我使用的身高和體重它的正常工作,但我想轉換進入高度(釐米)的Feet'inches轉換身高(釐米),以使用Javascript
HTML
計算BMI//height in Centimeter
<input type="number" onblur="myFunction()" min="0" name="height" id=height_' + len + ' class="txtInput2 personalize-form box-width" required/>
//Weight
<input type="number" onblur="myFunction()" min="0" name="weight" id=weight_' + len + ' class="txtInput4 personalize-form box-width" required/>
的Javascript
function myFunction(){
var height = document.getElementById("height_1").value;
var weight = document.getElementById("weight_1").value;
if(weight > 0 && height > 0){
var finalBmi = weight/(height/100*height/100)
document.bmiForm.bmi.value = finalBmi
if(finalBmi < 18.5){
var health= document.bmiForm.meaning.value = "UW"
}
if(finalBmi > 18.5 && finalBmi < 25){
var health1= document.bmiForm.meaning.value = "IW"
alert(health1);
}
if(finalBmi > 25){
var health2= document.bmiForm.meaning.value = "OW"
alert(health2);
}
}
else{
//alert("Please Fill in everything correctly")
}
}
和一英尺12英寸,應該是微不足道的數學?首先寫在紙上,然後寫JS代碼來做同樣的計算 – adeneo
它已經在堆棧中討論過。請參考[this](http://stackoverflow.com/questions/16541392/convert-centimeters-to-英寸) – Thala