LearnFast.Ninja

How to get value from textbox in JavaScript in html

Main idea: Use getElementById function and its value property. Test our Working example code.

Main idea: Use getElementById function and its value property. 
document.getElementById('Search_Text').value
 
Working example code: 

<html>

<head>

</head>

<body>

    <input type="text" id="Search_Text" size="40" />

    <input type="submit" value="Search"

        onclick="alert(document.getElementById('Search_Text').value)" />

</body>

</html>

 
Result: 


Tags

javascript

getelementbyid textbox