我是 javascript 的新手,并且正在跌跌撞撞地通过它。我正在尝试使用 javascript 来计算基于表单中三个不同值的值。问题是我得到的唯一输出是: [ Line: 00004 { (null) } ] : Null null.valueAsNumber cannot convert to Object
这是示例代码:
function YellowPay(aNames) {
var MaxYellow, YellowMil, YellowGallons, Mil, PayGals;
MaxYellow = this.getField(aNames[1]).valueAsNumber;
YellowMil = this.getField(aNames[2]).valueAsNumber;
YellowGallons = this.getField(aNames[3]).valueAsNumber;
Mil = Math.round(YellowMil * 100) / 100;
PayGals = "";
if (Mil >= 25) {
PayGals = MaxYellow;
} else if (Mil >= 20) {
PayGals = YellowGallons;
} else if (Mil >= 18) {
PayGals = YellowGallons * 0.75;
} else if (Mil >= 17) {
PayGals = YellowGallons * 0.5;
} else {
PayGals = 0;
}
YellowPay = PayGals;
}
event.value = YellowPay(["MaxYellow", "YellowMil", "YellowGallons"]);