如果...条件错误 [英] If..else condition error

查看:71
本文介绍了如果...条件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚以下代码有什么问题。代码在表中搜索值并分配mxCost。 IF..ELSE条件适用于除1之外的所有值,并且还读取表格。 IF条件使页面崩溃,我无法弄清楚为什么?有人可以帮我弄清楚我在这里做错了什么。任何帮助将不胜感激。谢谢。



我尝试了什么:



I am trying to figure out what is wrong with this following code. The code searches for value in a table and assigns mxCost. The IF..ELSE condition works for all values except 1 and is also reading the table. The IF condition makes the page crash and i am not able to figure out why? Can someone please help me figure out what i am doing wrong here. Any help will be appreciated. Thank you.

What I have tried:

$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 (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);

推荐答案

jq(#airTableValues tbody tr)。each(function (){
var monthName = months [parseInt(dateSplit [1]) - 1] ++ dateSplit [0];
if(monthName ==
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(0)").text().trim()) { mxCost =


jq(这个).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;
} //不工作!
else(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);
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 (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);


这篇关于如果...条件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆