This topic is locked
[SOLVED]

 Help with Javascript

1/24/2020 3:03:45 PM
PHPRunner General questions
S
swanside author

Hi All

At present i have this code

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

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

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

var ctrlTax = Runner.getControl(pageid, 'Tax');



function func() {

ctrlTotal.setValue((+ctrlPrice.getValue()) * (+ctrlQuantity.getValue())*(+ctrlTax.getValue()/100)+((+ctrlPrice.getValue())*(+ctrlQuantity.getValue())));

};



ctrlPrice.on('keyup', func);

ctrlQuantity.on('keyup', func);

ctrlTax.on('keyup', func);


I want to include another field which will be ctrlSubTotal, so I will have two setValue, now do I make a new line of code, or is there a way I can have sometihng like ctrlTotal.setValue AND ctrlSubTotal.setValue

Thanks

paul

S
swanside author 1/24/2020

Did it this way

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

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

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

var ctrlTax = Runner.getControl(pageid, 'Tax');

var ctrlSubTotal = Runner.getControl(pageid, 'SubTotal');



function func() {

ctrlSubTotal.setValue((+ctrlPrice.getValue()) * (+ctrlQuantity.getValue())*(+ctrlTax.getValue()/100));

ctrlTotal.setValue((+ctrlPrice.getValue()) * (+ctrlQuantity.getValue())*(+ctrlTax.getValue()/100)+((+ctrlPrice.getValue())*(+ctrlQuantity.getValue())));

};



ctrlPrice.on('keyup', func);

ctrlQuantity.on('keyup', func);

ctrlTax.on('keyup', func);




Hi All

At present i have this code

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

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

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

var ctrlTax = Runner.getControl(pageid, 'Tax');
function func() {

ctrlTotal.setValue((+ctrlPrice.getValue()) * (+ctrlQuantity.getValue())*(+ctrlTax.getValue()/100)+((+ctrlPrice.getValue())*(+ctrlQuantity.getValue())));

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

ctrlQuantity.on('keyup', func);

ctrlTax.on('keyup', func);


I want to include another field which will be ctrlSubTotal, so I will have two setValue, now do I make a new line of code, or is there a way I can have sometihng like ctrlTotal.setValue AND ctrlSubTotal.setValue

Thanks

paul