+ 1

How can we take the html input to JavaScript and then use it ?

I am trying​ to construct the basic calculator page so I need the input numbers to taken by JavaScript and then print the result in other html element. Please help

15th Jul 2017, 6:34 AM
G.S.N.V. Suraj
G.S.N.V. Suraj - avatar
1 Answer
+ 5
Get the element reference with such methods as .getElementById() and access its 'value' attribute (read/write access): <input type="text" id="myInput"> <script> var inp = document.getElementById('myInput'); alert(inp.value); </script>
15th Jul 2017, 6:41 AM
visph
visph - avatar