I would like to display the results calculated by JavaScript in HTML.

Asked 4 months ago, Updated 4 months ago, 10 views

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
console Error

After entering height (m) in the input form, the appropriate weight is displayed.

Reproduction Steps
Execute the following code.


<!DOCTYPE html>
    <title> Find the right weight by the square of height (m) x 22</title>
    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>


'use strict';

var calculation = document.getElementById('calculation');

  vareleHeight= document.getElementById("height");

  function calc(){

  var heightSquared=Math.power(height,2);
  var approveWeight=heightSquared*22;

  console.log (approachWeight);
  var result = approveWeight;
  result.innerHTML = "approduceWeight";

The height you enter is not centimeters, but meters.

javascript html5

2022-09-30 11:12

1 Answers

var calculation= document.getElementById('calculation');

What about calculation?
It's a spelling mistake.

2022-09-30 11:12

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.