This topic is locked
[SOLVED]

 JavaScript OnLoad Events

3/4/2015 7:48:46 PM
PHPRunner General questions
P
pmorenoc07 author

Helo;
I'm trying to calculate values on master/details during loading the page.
If I use keyup , change etc it works but not with onload.

Is there a way to do that??
Thanks.
var ctrlPrice = Runner.getControl(pageid, 'Price');

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

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

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

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

ctrlQuantity.on('onload', func);

Sergey Kornilov admin 3/5/2015

Input controls do not have 'onload' event. What you can do is just call func() function right there, at the end of your event.

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

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

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

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

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

ctrlQuantity.on('onload', func);

func();
P
pmorenoc07 author 3/5/2015



Input controls do not have 'onload' event. What you can do is just call func() function right there, at the end of your event.

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

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

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

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

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

ctrlQuantity.on('onload', func);

func();



It works calling func() at the end, but when I click Save for some reason it clear the total values in each single record in the view page , but it keep the Subtotal and Grand Total though.

What may be the problem then?

Thank you.

Sergey Kornilov admin 3/5/2015

I think you have some other code that might be doing that. I'm not seeing how the code you posted will do that when record is being saved.

P
pmorenoc07 author 3/5/2015



I think you have some other code that might be doing that. I'm not seeing how the code you posted will do that when record is being saved.


Well I'am using the Invoice template but items are generated from other table.

This invoice has an external jsfunctions.js