This topic is locked

Add 15% to total value

6/1/2018 2:42:31 AM
PHPRunner General questions
G
gagsoft author

Hi All
I am working on sample code that multiplies quantity with the price of a product.

I want to add 15 % VAT to the total.

The first bit works fine but adding the 15% VAT gives a syntax error.
Here is the code:

var ctrlPrice = Runner.getControl(pageid, 'Price');

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

var ctrlTotal = Runner.getControl(pageid, 'Total');

var ctrlTotalInc = Runner.getControl(pageid, 'TotalInc')
function func() {

ctrlTotal.setValue(parseFloat(ctrlPrice.getValue()) * parseFloat(ctrlQuantity.getValue()));

ctrlTotalInc.setValue(parseFloat(ctrlTotal.getValue())* 1.15));
};
ctrlPrice.on('keyup', func);

ctrlQuantity.on('keyup', func);

ctrltotal.on('keyup', func);


Microsoft JScript compilation error: Expected ';'
Would appreciate any pointers on this.
Best

Peter G

HJB 6/1/2018

https://xlinesoft.com/phprunner/docs/how_to_calculate_values_on_the_fly.htm
... seems as if some of your "parsefloat" brackets are missing respectively not set.

A
Andrew S 6/1/2018

Looks like you have missed ; at the end of
var ctrlTotalInc = Runner.getControl(pageid, 'TotalInc')

G
gagsoft author 6/12/2018



Looks like you have missed ; at the end of
var ctrlTotalInc = Runner.getControl(pageid, 'TotalInc')