2012-10-27 4 views
0

이 특정 라인이 전체 코드자바 스크립트 예상치 못한 예기치 않은 식별자

function metricComputation() { 
    var age = document.getElementById("age"); 
    var weightInlbs = document.getElementById("weight"); 
    var heightInInches = feetToInches(new Number(document.getElementById("heightinFt")) , document.getElementById("heightinIn")); 
    var bmr; 
    var gender = document.getElementById("gender"); 


    if(gender === "male"){ 
     bmr = 66 + (6.23 * weightInlbs) + (12.7 heightInInches) - (6.8 * age); 
    } 

} 

입니다 그리고 이것이

`Unexpected identifier` 

    bmr = 66 + (6.23 * weightInlbs) + (12.7 heightInInches) - (6.8 * age); 

입니다 전체 마크 업

<!DOCTYPE> 
<html> 
    <head> 
     <script src="bmrcalc.js"></script> 
    </head> 
     <body> 
      <center> 
        <h1>Basal Metabolic Rate</h1> 
       Height: <input type = "text" id ="heightinFt"> ft <input type = "text" id = "heightinIn"> in <br> 
       Weight: <input type = "text" id ="weight">lbs<br> 
       Age: <input type = "text" id = "age"><br> 
       Gender:<select id = "gender"> 
        <option value = "male">Male</option> 
        <option value = "female">Female</option> 
       <select> <br> 
       <button onclick = "metricComputation()">Compute</button> 
       <div id = "result"></div> 
      </center> 
     </body> 
</html> 
+0

예외가 나타나는 코드 열을 확인하십시오. – Bergi

답변

2

번식하셨습니까? 식별자 heightInInches이 위치에있을 것으로 예상되지

12.7 heightInInches 

:

bmr = 66 + (6.23 * weightInlbs) + (12.7 * heightInInches) - (6.8 * age); 
// -----------------------------------------/\ 
+1

오류가 발생하지 않았으므로 다시 netbook에 코드를 작성하지 않습니다. – user962206

0

는 여기에 버그. - 무엇 예상되는 것은 연산자와 같은 *, +, 또는/

0
if(gender === "male"){ 
    bmr = 66 + (6.23 * weightInlbs) + (12.7 * heightInInches) - (6.8 * age); 
} 

당신은 당신은 ""12.7 "사이에"* "누락 heightInInches된다 (12.7 heightInInches)

0

*을 잊었 :

bmr = 66 + (6.23 * weightInlbs) + (12.7 * heightInInches) - (6.8 * age); 
관련 문제