I need some help finishing the javascript for a form where users input numbers and the numbers are put into an equation and solved. I am pretty sure I have all of the HTML done correctly but the Javascript code is throwing me.
Any help in figuring this out is appreciated. I have hard time understanding Javascript all together.
function calculateMph() {
var feet = document.getElementById("inputFeet").value; //distance in feet
var time = document.getElementById("inputSeconds").value; //speed in seconds
var mph = (45 * feet) / (22 * time); //the equation here
document.write("<p>Your speed in mph is " + mph + "</p>");
}
<h1>Lab: Chapter Two</h1>
<h3>Fill in the form to determine your speed in miles per hour for a particular race that you ran:</h3>
<p><strong>MPH=(15f/22t) <br></strong>where f=distance run in feet and t is time in seconds.</p>
<form id="form">
Distance in Feet(f):<input id="inputFeet" type="text" name="feet" required><br> Number of Seconds(t):<input id="inputSeconds" type="text" name="seconds" required><br><br>
<input type="button" onclick="calculateMph()" value="Calculate" />
</form>
<p><b>Your speed in MPH:</b><br>
<span id="result"></span>
</p>