I want to make a simple HTML web page with simple formula. I have tried 2 ways - one with only HTML and it worked - and another with HTML + JS or so called DOM. The second one didn't work and I don't know why. I am sure that there are multiple problems.
Final result is a page where you enter a number (Fahrenheit for example) and get Celsius below instantly. I cant get it to work at all.
JS keeps getting string as a value instead of a number and I don't understand why. All examples are about text but none with numbers.
.value
doesn't help. <input>
doesn't work. NaN and undefined errors 24/7.
var inData = document.getElementById("input");
var ouData = document.getElementById("output");
inData.onblur = update;
inData.onkeydown = update;
inData.onkeyup = update;
inData.onkeypress = update;
function update() {
var ouData = (5 / 9) * (inData - 32);
document.getElementById("output").innerHTML = ouData.value;;
}
<input id="input" type="number">
<hr> Result=
<p id="output"></p>
simplified as much as possible
Want to understand whats the problem. New to JS - one day of experience.