HTML AND JAVASCRIPT | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

HTML AND JAVASCRIPT

how can i get the input from html form (input is number) then store in a variable in javascript so that i manipulate those number through javascript????????

7th Aug 2019, 1:29 PM
Najmuddin Ansari
Najmuddin Ansari - avatar
3 Answers
+ 5
You can assign the value of the input field of the form to a variable in the script, e.g. let a = document.getElementById ( 'inputFieldId' ).value; You get, however, a string from that, so you would have to parse it to a number by using parseInt() or parseFloat() before using it. Reference: https://www.w3schools.com/jsref/prop_text_value.asp
7th Aug 2019, 1:43 PM
Shadow
Shadow - avatar
+ 1
Many learn
13th Aug 2019, 2:41 AM
ALIS
18th Aug 2019, 7:07 PM
Subhodeep Chandra
Subhodeep Chandra - avatar