I'm new to javascript, and am stumbling through it. I am trying to use javascript to calculate a value based on three different values in the forms. the problem is that the only output I get is: [ Line: 00004 { (null) } ] : Null null.valueAsNumber cannot convert to Object
Here is the sample code:
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"]);