symptoms
I want to calculate the appropriate weight (calculated by the square of height (m) x 22) in JavaScript, but nothing happens when I enter height (m) entered from index.html.An error appears in the console.
Below is the actual console error
Expectations
After entering height (m) in the input form, the appropriate weight is displayed.
Reproduction Steps
Execute the following code.
index.html
<!DOCTYPE html>
<html>
<head>
<metacharset="UTF-8">
<title> Find the right weight by the square of height (m) x 22</title>
</head>
<body>
Height (m): <input type="number" step="0.01"><br>
<input type="submit" value="send" id="calculation">
Proper Weight (kg): <pid="result">/p>
<script type="text/javascript" src="calculation.js"></script>
</body>
</html>
calculation.js
'use strict';
var calculation = document.getElementById('calculation');
calculation.addEventListener('submit',(e)=>{
vareleHeight= document.getElementById("height");
function calc(){
varheight=parseFloat(eleHeight.value);
var heightSquared=Math.power(height,2);
var approveWeight=heightSquared*22;
};
console.log (approachWeight);
var result = approveWeight;
result.innerHTML = "approduceWeight";
});
Supplementary
The height you enter is not centimeters, but meters.
var calculation= document.getElementById('calculation');
What about calculation
?
It's a spelling mistake.
© 2024 OneMinuteCode. All rights reserved.