Reputation: 29
<form name="test_form">
<input id="demo" type="text" value="">
</form>
<button onclick="data()">GO</button>
<script>
var x=document.getElementById("demo");
function data()
{
x.innerHTML="TEST";
}
</script>
I am trying to input JavaScript function into input field but I've got a problem with that, nothing is happening, any ideas how to fix it?
Upvotes: 1
Views: 117
Reputation: 1323
<script>
function data()
{
var x=document.getElementById("demo");
x.value="TEST";
}
</script>
<form name="test_form">
<input id="demo" type="text" value="">
</form>
<button onclick="data();">GO</button>
Upvotes: 0