<script type = "text/javascript" >
function calc() {
var date = document.getElementById("date").value;
var location = document.getElementById("location").value;
var db1 = document.getElementById("db1").value;
var db2 = document.getElementById("db2").value;
var truckno = document.getElementById("truckno").value;
var rate = document.getElementById("rate").value;
rate = parseFloat(rate);
var rate14 = document.getElementById("14rate").value;
rate14 = parseFloat(rate14);
var rate19 = document.getElementById("19rate").value;
rate19 = parseFloat(rate19);
var kms = document.getElementById("kms").value;
kms = parseFloat(kms);
var kme = document.getElementById("kme").value;
kme = parseFloat(kme);
var pricens14 = document.getElementById("14nsprice").value;
pricens14 = parseFloat(pricens14);
var prices14 = document.getElementById("14sprice").value;
prices14 = parseFloat(prices14);
var price19 = document.getElementById("19price").value;
price19 = parseFloat(price19);
var a1 = document.getElementById("a1").value;
a1 = parseFloat(a1);
var b1 = document.getElementById("b1").value;
b1 = parseFloat(b1);
var c1 = document.getElementById("c1").value;
c1 = parseFloat(c1);
var a2 = document.getElementById("a2").value;
a2 = parseFloat(a2);
var b2 = document.getElementById("b2").value;
b2 = parseFloat(b2);
var c2 = document.getElementById("c2").value;
c2 = parseFloat(c2);
var total_cyl_loaded = a1 + b1 + c1;
total_cyl_loaded = parseFloat(total_cyl_loaded);
var total_cyl_returned = a2 + b2 + c2;
total_cyl_returned = parseFloat(total_cyl_returned);
var ns14_diff = a1 - a2;
ns14_diff = parseFloat(ns14_diff);
var sold_out_14 = ns14_diff * rate14;
sold_out_14 = parseFloat(sold_out_14);
var total_cyl_loaded = a1 + b1 + c1;
total_cyl_loaded = parseFloat(total_cyl_loaded);
var total_cyl_returned = a2 + b2 + c2;
total_cyl_returned = parseFloat(total_cyl_returned);
var ns14_diff = a1 - a2;
ns14_diff = parseFloat(ns14_diff);
var n19_diff = c1 - c2;
ns19_diff = parseFloat(ns19_diff);
var sold_out_14 = ns14_diff * rate14;
sold_out_14 = parseFloat(sold_out_14);
var sold_out_19 = n19_diff * rate19;
sold_out_19 = parseFloat(sold_out_19);
var price_14ns_returned = a1 * pricens14;
price_14ns_returned = parseFloat(price_14ns_returned);
var price_14s_returned = a2 * prices14;
price_14s_returned = parseFloat(price_14s_returned);
var price_19_returned = a * price19;
price_19_returned = parseFloat(price_19_returned);
var run_km = kme - kms;
run_km = parseFloat(run_km);
var truck_km_rate = run_km * rate;
truck_km_rate = parseFloat(truck_km_rate);
var total_cash_returned = price_14ns_returned + price_14s_returned + price_19_returned + sold_out_14 + sold_out_19 + truck_km_rate;
}
</script>
<input type="button" id="bbtn" name ="btn" onclick="calc();" value="Calculate">
答案 0 :(得分:0)
根据您的评论错误在于:
var n19_diff = c1 - c2;
ns19_diff = parseFloat(ns19_diff);
您将变量声明为n19_diff
,但尝试parseFloat
名为ns19_diff
的变量 - 它不存在 - 请注意变量声明中缺少的s