<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    user name:
    <input type="text" id="t1">
    <br>
    <button type="button" onClick="myFunction()">display</button>
    <script type="text/javascript">
        function myFunction() {
            var str;
            str = document.getElementById("t1");
            alert(str);
        }
    </script>
</body>
</html>
In the above program it is displaying [object] inside the alert box,I don't know why,I want to display what ever user input in the text box.help me..........
 
     
     
     
     
    