我想弄清楚以下代码有什么问题。代码在表中搜索值并分配mxCost。 IF..ELSE条件适用于除1之外的所有值,并且还读取表格。 IF条件使页面崩溃,我无法弄清楚为什么?有人可以帮我弄清楚我在这里做错了什么。任何帮助将不胜感激。谢谢。
$jq("#airTableValues tbody tr").each(function() {
var monthName = months[parseInt(dateSplit[1])-1]+" "+dateSplit[0];
if(monthName==$jq(this).find("td:eq(0)").text().trim())
{
mxCost = $jq(this).find("td:eq(6)").text().trim();
}
});
if (mxCost)
mxCost = (mxCost.substring(1, mxCost.length));
else {
mxCost = 0;
}
var MxStat = document.getElementById("MxStat").value;
MxStat = MxStat/100;
var InflationRate1 = document.getElementById("InflationRate1").value;
InflationRate1 = InflationRate1/100;
var rate3 = document.getElementById("rate3").value;
rate3 = Math.pow(1+rate3/100,1/365)-1;
var mxAdj;
if (MxStat == 1){
mxAdj = mxCost;
} // <------- NOT WORKING!
else if (MxStat != 1) {
var TotalCost = mxCost * 2;
mxAdj = (TotalCost * MxStat) - mxCost;
}
var ReturnVal = (mxAdj * InflationRate1) + mxAdj;
var ReturnCalc = ReturnVal * 1000000;
var ReturnPV = Math.floor(ReturnCalc/Math.pow(1+rate3,periods));
document.getElementById("ReturnCondition").value =
(ReturnPV/1000000).toFixed(2);
ReturnCondition = ReturnVal.toFixed(2);
答案 0 :(得分:-1)
这对我有用
if (MxStat != 1){
var mxAdj = (TotalCost * MxStat) - mxCost;
var ReturnVal = (mxAdj * InflationRate1) + mxAdj;
aReturnCondition = ReturnVal.toFixed(2);
}
if (MxStat == 1){
var mxAdj = mxCost;
var ReturnVal = (mxAdj * InflationRate1) + mxAdj;
aReturnCondition = parseFloat(ReturnVal).toFixed(2);}