Answers for "js function take html input"

8

how to read an input from HTML in javascript

<!--
This is example is with a number...
But you can do it with whatever input type you want
-->
<input type="number" name="numberInput" id="numberInput" max="20" min="1" step="1">
<button type="button" onclick="myFunction()">sumbit</button>

<script>
  function myFunction() {
    let tokenAmount = document.getElementById("numberInput").value;
    return // whatever you want to do with it
  }
</script>
Posted by: Guest on September-15-2021
0

how to input from user in javascript

var name = prompt("Please enter your name", "Harry Potter");
Posted by: Guest on August-11-2021

Browse Popular Code Answers by Language