I am trying to build a simple budget calculator, everytime I click my submit button I nothing happens. When I try to check my variable values in the console they show null, even after I have typed values in my input boxes. Can anyone tell me what I'm doing wrong? After looking through other questions on here I haven't been able to find an answer that relates to my issue.
<!DOCTYPE html>
<html>
<head>
<title>Budget Calculator</title>
<style>
input {display:block;}
#clear {float:left;}
#submit {float:left;}
</style>
<script type="text/javascript">
var kms = document.getElementById("kmTravelled");
var rent = document.getElementById("rentPerMonth");
var carCost = document.getElementById("carPayment");
var costPerTrip = (kms/12.75)*20;
var total = Math.round((costPerTrip + rent + carCost)*100)/100;
function calculate()
{
document.getElementById("calculator").innerHTML = total;
}
</script>
</head>
<body>
<form id="myForm")>
Km travelled per day: <input type="number" name="kmTravelled" />
Rent per month: <input type="number" name="rentPerMonth" />
Car payment per month: <input type="number" name="carPayment" />
</form>
<button id="submit" type="button" onclick="calculate();">
Submit
</button>
<button id="clear" type="clear">
Clear
</button>
<p id = "calculator">
</p>
<script>
calculate();
</script>
</body>
<form id="myForm")>you have a closing parenthesis to much.