Get the value of a text field:
var x = document.getElementById("myText").value;
Click the button to display the value attribute of the text field.
<!DOCTYPE html> <html> <body> First Name: <input type="text" id="myText" value="Mickey"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w .j a v a2s . c o m*/ var x = document.getElementById("myText").value; document.getElementById("demo").innerHTML = x; } </script> </body> </html>