So basically I'm trying to get a name that is entered in a text input box in the body to show in an alert in script but it always displays the name as null or if I put .value on the end of the document.getElementById("name") it doesn't display anything. I'm confused because in all the tutorials I've seen it always says to just do it like I did it...
Here's the code I was using:
<!DOCTYPE html>
<html>
<script>
var name = document.getElementById("name");
function showName()
{
alert ("Your name: " + name)
}
</script>
<body>
<form name = "form">
Please enter your full name <input type = "text" id = "name"><br>
<input type = "button" value = "show name" onclick = "showName()">
</form>
</body>
</html>