1document.getElementById("myInputID").value = "My Value"; //set value on myInputID
1<!DOCTYPE html>
2<html lang="en">
3<head>
4<meta charset="utf-8">
5<title>Get Text Input Field Value in JavaScript</title>
6</head>
7<body>
8 <input type="text" placeholder="Type something..." id="myInput">
9 <button type="button" onclick="getInputValue();">Get Value</button>
10
11 <script>
12 function getInputValue(){
13 // Selecting the input element and get its value
14 var inputVal = document.getElementById("myInput").value;
15
16 // Displaying the value
17 alert(inputVal);
18 }
19 </script>
20</body>
21</html>
1<!-- for simplicity's sake, I have the js code and html in the same file -->
2<!-- 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 -->
3
4<html lang="en">
5<head>
6<meta charset="utf-8">
7<title>Get Text Input Field Value in JavaScript</title>
8</head>
9<body>
10 <input type="text" placeholder="Type something..." id="myInput">
11 <button type="button" onclick="getInputValue();">Get Value</button>
12
13 <script>
14 function getInputValue(){
15 // Selecting the input element and get its value
16 var inputVal = document.getElementById("myInput").value;
17
18 // Displaying the value
19 alert(inputVal);
20 }
21 </script>
22</body>
23</html>
1var view = require("ui/core/view");
2function pageLoaded(args) {
3 var page = args.object;
4 var textfield= view.getViewById(page, "textfieldID");
5}
6var text = textField.text;