So I'm trying to have someone enter their name on one page and then on another page it will say Hello, entered_name. Here's what I have: First Page:
<!DOCTYPE html>
<html>
<body>
<form action="SecondPage.html">
<input type="text" id="uname">
</form>
</body>
</html>
Second Page:
<html>
<body>
<script type="text/javascript" src="main.js"></script>
<script>myFunction();</script>
</body>
</html>
Javascript:
function myFunction()
{
var person = document.getElementById("uname")
document.write("Hello " + person);
}
The output is Hello null.
Can someone help me figure out how to fix this? I'm very new to Javascript I'm trying to learn how to use external Javascript. I've tried adding $(document).ready(function() with and downloading jquery and moving it to the folder with the other files. But I don't know if that was all I had to do for that so maybe that's the problem. I don't know. I also don't know if that's the right way to access the formdata. There seem to be many different ways and I've tried a few.
Thanks for any suggestions.