Click to See Complete Forum and Search --> : HTML code error?


cbcatanz
10-30-2006, 11:41 AM
I was wondering if someone could take a look at my HTML code and see where I've made a mistake. I've been going over it for the last hour or so. Here is the code:

<html>

<head>
<title>mpg</title>
</head>

<body>
<h3 style="text-align: center">Miles traveled and Gallons used converted to Miles per gallon Conversion page</h3>

<script type="text/javascript">
milestraveled = prompt("Enter the amount of miles you traveled:");
milestraveled = parseFloat(milestraveled);

gallonsused = prompt("Enter the amount of gallons of gas that was used:");
gallonsused = parseFloat(Gallonsused);

mpg = (milestraveled/gallonsused);

document.write("You entered " + milestraveled + " miles traveled and " + gallonsused + " gallons of gas used.<br />");
document.write("That is " + mpg + " miles per gallon. ");
</script>
</body>
</html>



The problem I am having is after the prompt for miles traveled and gallons of gas used no results are displayed. I think the problem may be the mpg = (milestraveled/gallonsused); part of the code, but I'm not sure. Can someone give me an idea where I messed up.

TheBearMay
10-30-2006, 11:43 AM
gallonsused = parseFloat(Gallonsused);


Should be

gallonsused = parseFloat(gallonsused);

cbcatanz
10-30-2006, 11:45 AM
gallonsused = parseFloat(Gallonsused);


Should be

gallonsused = parseFloat(gallonsused);


Do I feel stupid............ Such an easy fix. Thank you so much, TBM.

Kor
10-30-2006, 11:46 AM
javascript is case-sensitive

parseFloat(gallonsused)