1

I wrote a program to convert centimeter to inch

In this program everything is correct but the output is not showing

function click() {
  let cmVal = Number(document.getElementById("input").value)
  let inch = cmVal / 2.54
  let result = document.getElementById("result")
  result.innerHTML = inch
}
<div id="container">
  <h3>Calculation</h3>
  <div class="input val">
    <input type="text" id="input" placeholder="enter cm value">
  </div>
  <div>
    <button type="submit" onclick="click()">convert to inches</button>
  </div>
  <div id="result">

  </div>
</div>
kennarddh
  • 2,186
  • 2
  • 6
  • 21
Sharjan C
  • 11
  • 1
  • Try adding some `console.log('...')` statements to your script - do you see the output in the Console of your browser's dev tools? Any other messages there? – Hans Kesting Apr 21 '23 at 08:32
  • 2
    In other words - rename your function to be more unique, e.g. `clickFn` – Justinas Apr 21 '23 at 08:34
  • 3
    As you can see from duplicate question link the problem is the name of function, i raccomend to used `addEventListener` instead of inline event. – Simone Rossaini Apr 21 '23 at 08:35

0 Answers0