What is wrong with this Javascript?
At line 29 of this javascript it comes out with the following error when the function is evoked it comes out with the following message document.price1.value is null or not an object any ideas why folks?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--
function CalculateCost(miles,price)
{
var litres;
var cost;
litres = miles / 8;
cost = price * litres;
cost = cost.toFixed(2);
alert(cost);
}
function DisplayValue()
{
var price = document.price1.value;
alert(price);
}
//-->
</script>
</head>
<body>
<p>Number of Miles</p>
<p><input type="text" value="0" name="miles1"/><p>
<p>Price per litre</p>
<p><input type="text" value="0" name="price1" onchange="DisplayValue()"/></p>
<input type="button" value="Caculate" onclick="CalculateCost(200,1.13)"/>
</body>
</html>
|