I want to make a calculation form where you would input numbers and when you click calculate and it will calculate the result | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I want to make a calculation form where you would input numbers and when you click calculate and it will calculate the result

<label>Feet</label> <input id="x" type="number" placeholder="Feet" required> <label>final</label> <input id="y" type="number" placeholder="..." disabled> <p> will calc<span div I’d="cal"></span> </p> <button onclick="f()"> calculate </button> <script> var x = 2; var y = 5; function f() { document.getElementById("cal").innerHTML = x + y; } </script>

4th Apr 2018, 8:04 PM
klisco1
2 Answers
+ 1
Neato! :) Post it up to us when you're done and we'll check it out + give you feedback on it. Btw, in your current version of the code, it should be id="cal" instead of div="cal" - just something I noticed at first glance. ;) (also, don't forget to put your JS inside of <script> tags or place it inside of JS tab) Best of luck to ya! If you run into any problems or have questions, don't hesitate to ask us. We'll get you pointed in right direction.
4th Apr 2018, 8:13 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 1
It’s in external style script
4th Apr 2018, 10:03 PM
klisco1