I want to use information from a text input for running a script with it. How can I take the information from a text input in html?
Asked
Active
Viewed 32 times
0
-
2There are a ton of ways. See this post http://stackoverflow.com/questions/11563638/javascript-get-input-text-value – Mike.Alvarez May 30 '16 at 18:11
1 Answers
1
this example help you :
<html>
<head>
</head>
<body>
<input type="text" id="txt" value="this is text">
<button id="btn" onclick="fun()" >Click me</button>
<script>
function fun() {
var mytext= document.getElementById("txt").value;
alert(mytext);
}
</script>
</body>
</html>

Ehsan
- 12,655
- 3
- 25
- 44