I want to do this fuel economy checker thing, however it always gives me a NaN error in the alert box?
[code]
<html>
<head><title>Fuel Economy Checker</title></head>
<body>
<script language=”javascript”>
var kms=0;
var dollars=0;
document.write(“<form><table><tr><td>Kilometres Travelled</td><td><input name=”+kms+”></td>”+
“<tr><td>Dollars of Fuel Consumed</td><td><input name=”+dollars+”></td></table><br>”+
“<input type=’button’ name=’submit’ value=’Check it’ onClick=’checkit()’>”);
function checkit()
{
var answer=0;
dollars = dollars*10
answer = dollars/kms;
alert(answer+” cents per Km”);
}
</script>
</body>
</html>
What the hell? It should work, shouldn’t it? I defined the variables as number with the =0 on the end didn’t I?
Cheers
hamstar