I've been looking for an answer for this problem, but I feel like I need a much more in depth response from people, as I am a beginner to programming. Can someone please look over my code, and maybe test it out to identify my problem? My console keeps saying my addComment() function isn't defined. Here is my code:
<!Doctype HTML>
<html>
<head>
</head>
<body>
<section>
<p>Name:</p> <input type="text" id="Name"/>
<br/>
<br/>
<p>Text:</p>
<textarea rows="10" cols="25" id="Text"></textarea>
<input id="Post" type="submit" value="Post" onclick="return addCom()"/>
<br/>
<br/>
<h1 class="section">COMMENTS</h1>
</section>
<script>
var Post = document.getElementById("Post");
var Text = document.getElementById("Text").value;
var Name = document.getElementById("Name").value;
window.onload = function addCom() {
document.createElement("div").innerHTML = Name + "says:" + Text;
}
</script>
</body>
</html>
Please identify my problems and let me know. It would be appreciated if you could tell me why my console kept saying my function wasn't defined. Thank you.
Regards, Amiya