get value of input js code example
Example 1: javascript set input field value
document.getElementById("myInputID").value = "My Value"; //set value on myInputID
Example 2: Javascript get text input value
var inputValue = document.getElementById("myTextInputID").value;
Example 3: get value javascript
<!DOCTYPE html>
<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>
Example 4: get value from textbox in vanilla javascript
document.getElementById("myText").value = "Johnny Bravo";
Example 5: get the value of an input nativscript
var view = require("ui/core/view");
function pageLoaded(args) {
var page = args.object;
var textfield= view.getViewById(page, "textfieldID");
}
var text = textField.text;
Example 6: js input value
var x = document.getElementById("myText").value;