我是javascript的新手,我正在磕磕绊绊。我试图使用javascript根据表单中的三个不同值计算一个值。问题是我得到的唯一输出是: [Line:00004 {(null)}]:Null null.valueAsNumber无法转换为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"]);