I am very new to javascript and I was trying to populate a textbox from html with javascript but for some reason isn't working. This is what I have:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Relations</title>
<link rel="stylesheet" href="kandi.css" type="text/css" media="screen">
<script src="myscript.js"></script>
<body>
<h1 align="center" style="font-family:Arial;" >RELATION TAGGING </h1>
<textarea id="your_textarea" rows="15" cols="160">
</textarea>
</body>
</head>
</html>
Javascript:
var textarea = document.getElementById("your_textarea");
textarea.innerHTML = "testing123";
Textareas are not text inputs. Whereas input elements store the input in an attribute: <input value="foo">, textareas get them as content: <textarea>foo</textarea>. Use this instead:
textarea.textContent = "testing123"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With