รบกวนช่วยดู javascript ให้ทีครับ ไม่แน่ใจว่าผิดตรงไหน
บรรทัดที่ 10
var weight1 = document.bmrform.weight.value
บรรทัดที่ 16
finalBmr1 = 66.5+(13.75 * weigth1 ) + (5.003 * height1)- (6.755 * age1)
บรรทัดที่ 22
finalBmr1 = 655.1 + ( 9.563 * weigth1 ) + ( 1.850 * height1 ) - ( 4.676 * age1 )
แก้ไขบรรทัดที่ 16,22 จาก weigth1 ไปเป็น weight1
(พิมพ์อักษรตัว ????th1 กับ ????ht1)
ประวัติการแก้ไข 2017-07-06 01:59:55 2017-07-06 03:45:18
Date :
2017-07-06 01:58:47
By :
ccjpn
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script language="JavaScript">
function isNumberKey(evt,id)
{
try{
var charCode = (evt.which) ? evt.which : event.keyCode;
if(charCode==46){
var txt=document.getElementById(id).value;
if(!(txt.indexOf(".") > -1)){
return true;
}
}
if (charCode > 31 && (charCode < 48 || charCode > 57) )
return false;
return true;
}catch(w){
alert(w);
}
}
function calculateBmr(){
var finalBmr1
var age1 = document.bmrform.age
var weight1 = document.bmrform.weight
var height1 = document.bmrform.height
var gender1 = document.bmrform.gender
if(weight1.value > 0 && height1.value > 0 && age1.value > 0){
if(gender1.value=="male"){
finalBmr1 = 66.5+(13.75 * weight1.value) + (5.003 * height1.value)- (6.755 * age1.value)
document.getElementById('finalbmr').value = finalBmr1.toFixed(4)
}
if(gender1.value=="female"){
finalBmr1 = 655.1 + ( 9.563 * weight1.value ) + ( 1.850 * height1.value ) - ( 4.676 * age1.value )
document.getElementById('finalbmr').value = finalBmr1.toFixed(4)
}
}
else {
alert("Please Fill in everything correctly")
}
}
</script>
</head>
<body>
<form name="bmrform" method="post" action="">
<p class="green"><span class="green">
<label for="Age">
<input type="radio" name="gender" id="gender" value="male" checked> //เลือกเพศ
male
<input type="radio" name="gender" id="gender" value="female"> //เลือกเพศ
Female<br>
<br>
Age</label>
</span>
<label for="Age"></label>
<input type="text" name="age" id="age" onkeypress="return isNumberKey(event,this.id)"> //อายุ
year</p>
<p class="green">
<label for="weight_bmr">Weight</label>
<input type="text" name="weight" id="weight" onkeypress="return isNumberKey(event,this.id)"> //น้ำหนัก
(kg)
</p>
<p class="green">Height
<input type="text" name="height" id="height" onkeypress="return isNumberKey(event,this.id)"> //ส่วนสูง
(cm) </p>
<p class="green">
<input type="button" name="bmr" id="bmr" value="Calculate BMR" onClick="calculateBmr()"> //ปุ่มสั่งคำนวณ
</p>
<p class="green">
<label for="finalbmr">Your BMR</label>
<input type="text" name="finalbmr" id="finalbmr"> //แสดงผลการคำนวณ
kcal/day</p>
<p class="green"> </p>
<p class="green"> </p>
</form>
</body>
</html>
Date :
2017-07-06 03:27:45
By :
ccjpn
Load balance : Server 04