How to get user input? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to get user input?

I want to use <input> in HTML and use the value in JS. How?

20th Oct 2018, 10:35 AM
C. Scheler
C. Scheler - avatar
2 Answers
+ 3
use DOM var inputform = document.getElementById("inputform").value
20th Oct 2018, 10:43 AM
Taste
Taste - avatar
+ 1
with value attribute For example: <input onchange="myFunction()" id="input"/> <script> function myFunction(){ var myValue = document.getElementById("input").value; alert(myValue); } </script>
10th Nov 2018, 5:31 PM
Orsrozsondai
Orsrozsondai - avatar