Answers for "how to get value of a input box in javascript"

8

set value using javascript

document.getElementById("myText").value = "your string";
Posted by: Guest on August-28-2020
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
Posted by: Guest on June-30-2021

Code answers related to "how to get value of a input box in javascript"

Browse Popular Code Answers by Language