How can i use JavaScript to get the input value | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How can i use JavaScript to get the input value

How can i use JavaScript to get the value of the number i enter into the textbox. <input id="input" type="number" name="factor" placeholder="Enter A Number" /> <button id="factorize" name="factorize" onclick="factorize()">Factorize!</button>

4th Jun 2017, 8:32 AM
TheDavyLoper
TheDavyLoper - avatar
3 Answers
4th Jun 2017, 9:41 AM
Mrinal Bhagabati
Mrinal Bhagabati - avatar
+ 12
<script> // .value property onload=function(){ var input = document.getElementById("input"); var b = document.getElementById("factorize"); b.onclick=function(){ alert(input.value); } } </script>
4th Jun 2017, 9:00 AM
Maz
Maz - avatar
0
hey Maz thanks it worked
4th Jun 2017, 9:46 AM
TheDavyLoper
TheDavyLoper - avatar