0

how to return number values?

im trying to get number values from input tag but its return string https://code.sololearn.com/Wqp82P034ySM/?ref=app

17th Sep 2019, 10:18 AM
Sandy Harys
Sandy Harys - avatar
2 Answers
0
Try this bro: <script> function calc() { var bil1 =Number( document.getElementById("bil1").value); var bil2 =Number( document.getElementById("bil2").value); var result = bil1 + bil2; document.getElementById("rslt").innerHTML = result; alert (result); } </script>
17th Sep 2019, 10:27 AM
Thống Nguyễn
Thống Nguyễn - avatar
0
when you enter any value in the input field, a string value is written to your variable. Try function parseInt, to get a number value
17th Sep 2019, 11:54 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar