|
I thought } would function as script separator. Not true in this case. script below works for 2nd part only: "calc TWO"... if I comment out "calc TWO" script, 1st script works. Running both scripts produces 2nd result only. Have tried various bracket combinations accept the right one.
var ctrlSerChg = Runner.getControl(pageid, 'SerChg');
var ctrlPartsLabor = Runner.getControl(pageid, 'PartsLabor');
var ctrlTot_Amt_Calc = Runner.getControl(pageid, 'Tot_Amt_Calc');
function func() {
ctrlTot_Amt_Calc.setValue(Number(ctrlSerChg.getValue()) + Number(ctrlPartsLabor.getValue()));
};
ctrlSerChg.on('keyup', func);
ctrlPartsLabor.on('keyup', func); // calc TWO begins below
//var ctrlCounty = Runner.getControl(pageid, 'TaxCounty');
var ctrlSerChg2 = Runner.getControl(pageid, 'SerChg');
var ctrlPartsLabor2 = Runner.getControl(pageid, 'PartsLabor');
var ctrlTax7_Calc = Runner.getControl(pageid, 'Tax7_Calc');
function func() {
ctrlTax7_Calc.setValue((Number(ctrlSerChg2.getValue()) + Number(ctrlPartsLabor2.getValue())) * (.07));
};
ctrlSerChg2.on('keyup', func);
ctrlPartsLabor2.on('keyup', func);
What would really rock is the following calc based on additional table fields...
calc "CASE" works OK in sql, but not able to convert to javascript calc.
// calc TWO begins below
var ctrlCounty = Runner.getControl(pageid, 'TaxCounty');
var ctrlSerChg2 = Runner.getControl(pageid, 'SerChg');
var ctrlPartsLabor2 = Runner.getControl(pageid, 'PartsLabor');
var ctrlTax_Calc = Runner.getControl(pageid, 'Tax_Calc');
function func() { // Calc below based on other table fields. ctrlTax_Calc.setValue(((CASE
WHEN ((tbl_Invoices.PartsCost > 0.01) AND (Lu_Zip.St = 'Fl') AND
(Lu_Zip.County <> 'St Johns')) THEN (((IfNull(tbl_Invoices.SerChg,
0) + tbl_Invoices.PartsLabor) * 0.07) - tbl_Invoices.Tax)
WHEN ((tbl_Invoices.PartsCost > 0.01) AND (Lu_Zip.St = 'Fl') AND
(Lu_Zip.County = 'St Johns')) THEN (((IfNull(tbl_Invoices.SerChg, 0) +
IfNull(tbl_Invoices.PartsLabor, 0)) * 0.06) - tbl_Invoices.Tax)
END); };
ctrlSerChg2.on('keyup', func);
ctrlPartsLabor2.on('keyup', func);
Thanks for all feedback.
|