This topic is locked
[SOLVED]

 Calculated Field

10/29/2013 2:30:42 AM
ASPRunnerPro General questions
Y
yahia author

Hello i have a table : Invoice the cotains miutiple calculated the field are:

No

Product Name

Packing

CARTONS

QUANTITY

UNIT-PRICE

AMOUNT

UNIT-WEIGHT

Gross Weight

I want the the field QUANTITY to be calaculated as PACKINGCARTONS

AMOUNT = QUANTITY
UNIT-PRICE

GROSS WEIGHT = QUANTITYUNIT-WEIGHT

I used javascript onload event but :

var ctrlPacking = Runner.getControl(pageid, 'Packing');

var ctrlQuantity = Runner.getControl(pageid, 'Quantity');
function func() {

ctrlQuantity.setValue(Number(ctrlCtn.getValue())
Number(ctrlPacking.getValue()));

}
ctrlCtn.on('keyup', func);

ctrlPacking.on('keyup', func);
and it is working well and calculted the QUANTITY

but when i add a new event like:
// Place event code here.

// Use "Add Action" button to add code snippets.

var ctrlQuantity = Runner.getControl(pageid, 'Quantity');

var ctrlUnitprice = Runner.getControl(pageid, 'UnitPrice');

var ctrlAmount = Runner.getControl(pageid, 'Amount');
function func() {

ctrlAmount.setValue(Number(ctrlQuantity.getValue()) * Number(ctrlUnitprice.getValue()));

}
ctrlQuantity.on('keyup', func);

ctrlUnitprice.on('keyup', func);

then it give only 0 on AMOUNT and the quantity is no more calculated

I need help

Thanks in advance

Sergey Kornilov admin 10/29/2013

It's hard to tell what exactly might be wrong. My advice is to see if there are any Javascript errors there.

This article can help:

http://xlinesoft.com/blog/2012/05/22/how-to-troubleshoot-javascript-errors/

Y
yahia author 10/29/2013



It's hard to tell what exactly might be wrong. My advice is to see if there are any Javascript errors there.

This article can help:

http://xlinesoft.com...ascript-errors/


Thank you for your fast reply!

So in the same add page can I put two code to calculate more than one field?

What i should put to separate the two codes: the one that calcualtes the QUANTITY and the second that calculate the AMOUNT
like what is following:
var ctrlPacking = Runner.getControl(pageid, 'Packing');

var ctrlQuantity = Runner.getControl(pageid, 'Quantity');
function func() {

ctrlQuantity.setValue(Number(ctrlCtn.getValue()) Number(ctrlPacking.getValue()));

}
ctrlCtn.on('keyup', func);

ctrlPacking.on('keyup', func);
// Should put a code or a sign beofre or after this?

// did i forget any part of the code?
var ctrlQuantity = Runner.getControl(pageid, 'Quantity');

var ctrlUnitprice = Runner.getControl(pageid, 'UnitPrice');

var ctrlAmount = Runner.getControl(pageid, 'Amount');
function func() {

ctrlAmount.setValue(Number(ctrlQuantity.getValue())
Number(ctrlUnitprice.getValue()));

}
ctrlQuantity.on('keyup', func);

ctrlUnitprice.on('keyup', func);

Sergey Kornilov admin 10/29/2013

Yes, you can perform multiple calculations. You can either put all calculation code into the same function func() or create a new function named func2() that perform another set of calculations. Having two functions named "func" is definitely not going to work.