-1

目前我正在研究 Java 脚本项目。该项目用于检查从 UDDF 文件中选择的值与 UDDF 文件中的全部值。但用于比较的 if 语句不起作用。我已将我的代码放在下面

function parseUddf(){
var myArray=new Array("null","airportID","airportSiteNo","faaRgn","uddfVer","null","airportName","verificationDate",
"city","state","horizontalelevationdatum","horiAccuracy","elevAccuracy","orthoDatum","orthoAccuracy",
"magDec","verificationDate","airportOrthoElev","airportEllipsoidElev","airportElevationLoc",
"verificationDate","towerFloorOrthoElev","towerFloorEllipElev","verificationDate","arpLatitude","arpLongitude");
var selt=document.getElementById("textdis").value;
var x = document.getElementById("uddf").value;
x = x.split("@");
var x0 = x[0];
x0 = x0.split("|");
var j=x0.length;
alert(j);
for(var i=1;i<x0.length;i++){
        alert("selt="+selt.toString());
    if(selt.toString()==x0[i])
 {
          alert("success");
          alert("i="+i);
          alert(myArray[i]);
//document.getElementById("textdistitleid").value=myArray[i];
 break;
    }


    }
}

UDDF 文件值为:

|FAI |50219.A |AAL |1.07| |费尔班克斯国际机场 |1592011| |费尔班克斯 |阿拉斯加 | |NAD83 |5 厘米 |15 厘米 |NAVD88 |25 厘米 | |-20.4|1592011| | 439.0| 470.0|20R+3990|1592011| | 529.0| | | | 644854.4|-1475123.2|

我需要你的帮助

4

1 回答 1

0

==您可以使用 .equals()而不是使用:

selt.toString().trim().equals(x0[i].trim())

您可以从此处获取 javascript 的 trim() 函数

于 2013-01-16T05:31:59.417 回答