Can't seem to pass the mpg value to the milespergallon input text box. Any help on how to get this value in the box from the function. This is an online class and the instructor rarely replies to our email questions.

Thanks in advance.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<link rel="stylesheet" href="js_styles.css" type="text/css" />
<title>Miles Per Gallon Calculator</title>
<meta http-equiv="content-type" content="text/html;
charset=iso-8859-1" />
<script type="text/javascript">
/* <![CDATA[ */

function calcMPG(startingMiles, endingMiles, gallons) {

var startingMiles = parseInt(document.getElementById('startingmiles'). value);
var endingMiles = parseInt(document.getElementById('endingmiles').va lue);
var gallons = parseInt(document.getElementById('gallonsused').va lue);
var mpg = (endingMiles - startingMiles) / gallons;

?/* just writes to a new page not the mpg input text box*/
document.write(mpg.milespergallon = mpg);
}

/* ]]> */
</script>
</head>
<body>


<h1>Miles Per Gallon Calculator</h1>
<form name="mpg" action="">
<p><strong>Starting Mileage:</strong></p>
<p><input type="text" id="startingmiles" name="startingmiles" value=0 onchange="calcMPG(this)" /></p>
<p><strong>Ending Mileage:</strong></p>
<p><input type="text" id="endingmiles" name="endingmiles" value=0 onchange="calcMPG(this)" /></p>
<p><strong>Gallons Used:</strong></p>
<p><input type="text" id="gallonsused" name="gallonsused" value=0 onchange="calcMPG(this)" /></p>
<p><strong>Miles Per Gallon:</strong></p>
<p><input type="text" name="milespergallon" value=0 readonly="readonly" /></p>
</form>

<script type="text/javascript">
/* <![CDATA[ */

calcMPG();


/* ]]> */
</script>

<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
</p>

<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10-blue"
alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
</p>

</body>
</html>