photoxprt1868
Programmer
Hello,
I'm writing what I think is a simple formula, but it's working at all. Can someone tell me if there's anything wrong with my syntax
I'm writing what I think is a simple formula, but it's working at all. Can someone tell me if there's anything wrong with my syntax
Code:
<head>
<SCRIPT LANGUAGE="JavaScript">
function calculateCost(kwh){
var custCharge2005 = 5.25;
var custCharge2006 = 0;
var first750KWH = 0.04302;
var first750 = 0;
var over750KWH = 0.05232;
var over750 = 0;
var fuelCharge = 0.04009;
var cost2005 = 0;
var cost2006 = 0;
if (kwh > 750){
first750 = 750;
}
else{
first750 = kwh;
}
if (first750 < kwh){
over750 = kwh - first750;
}
else{
over750 = 0;
}
cost2005 = custCharge2005 + (first750kwh * first750) + (over750kwh * over750) + (fuelCharge * kwh) - 1.36;
alert(cost2005);
}
</script>
</head>
<body onLoad="calculateCost(1000);">
</body>