Answers for "get an input value with javascript"

8

set value using javascript

document.getElementById("myText").value = "your string";
Posted by: Guest on August-28-2020
56

Javascript get text input value

var inputValue = document.getElementById("myTextInputID").value;
Posted by: Guest on July-26-2019
3

get value of input js

<!-- for simplicity's sake, I have the js code and html in the same file -->
<!-- if you want to, you can add the js in another file and make a <script> tag and link it up to the html file -->

<html lang="en">
<head>
<meta charset="utf-8">
<title>Get Text Input Field Value in JavaScript</title>
</head>
<body>
    <input type="text" placeholder="Type something..." id="myInput">
    <button type="button" onclick="getInputValue();">Get Value</button>
    
    <script>
        function getInputValue(){
            // Selecting the input element and get its value 
            var inputVal = document.getElementById("myInput").value;
            
            // Displaying the value
            alert(inputVal);
        }
    </script>
</body>
</html>
Posted by: Guest on June-30-2021

Code answers related to "get an input value with javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language