I'm making a html document that holds two number fields.
The user enters the numeric info then clicks a button that activates a method on a separate .js file. The issue I'm running into is that every time you enter the data and press the button it returns the data as NULL
.
Here is what I have:
<html>
<head>
</head>
<body>
<h1>Retirement calculation page!</h1>
<p class="a">Enter the information below to find out how much money you will have for retirement</p>
<form name="form1">
Enter Age: <input type ="number" name="age1" min="1" max="125">
</form>
<form name="form2">
Enter Contribution amount: <input type="number" name="cont1">
</form>
<button onclick="rFunction()">Submit</button>
<script src="retirement.js"></script>
</body>
</html>
Here is the method in the .js file.
function rFunction()
{
var age = document.getElementById("age1");
var cont = document.getElementById("cont1");
document.write("Age = " + age );
document.write("Cont = " + cont );
}
What am I doing wrong?