This topic is locked
[SOLVED]

 Please wait message

8/7/2019 7:24:30 PM
PHPRunner General questions
A
AndrewMark author

I have a script that was set up in events in JavaOnload in the Add page. The user experience is that the script takes a long time to run. I am trying to improve the user experience so that:

  1. A "Please Wait" message comes up while the page is loading
  2. The script does not cut out during the upload
  3. Shorten the script load time
    I was wondering if anybody can give me guidance on implementing the above or any other suggestions to improve the experience or how to shorten long scripts.

admin 8/8/2019

Usually displaying any sort of messages, telling the user to wait, is a bad design. Improving your script performance is the way to go. You need to tell us more about what is happening and what takes that much time.

A
AndrewMark author 8/8/2019

Thanks for the advice. I have set up the following code in Events in the add page for Javascript onload. Please let me know if you think any of the below can be improved to fix the problem
Firstly we have used the following code per https://xlinesoft.com/phprunner/docs/how_to_calculate_values_on_the_fly.htm

this has approximately 170 variables, followed by approximately 25 functions (mainly addition, subtraction type functions), followed by approximately 130 keyups
some of the 170 variable examples are:
var ctrlRev = Runner.getControl(pageid, 'OrdinaryRevenue');

var ctrlCogs = Runner.getControl(pageid, 'CostofGoodsSold');

var ctrlGrossprof = Runner.getControl(pageid, 'GrossProfit');

var ctrlOtherinc = Runner.getControl(pageid, 'OtherIncome');
some of the 25 functions examples are:
function func() {

ctrlGrossprof.setValue(Number(ctrlRev.getValue()) - Number(ctrlCogs.getValue()));

ctrlTotalexp.setValue(Number(ctrlAccfees.getValue()) + Number(ctrlDepre.getValue())+ Number(ctrlInsuran.getValue())+ Number(ctrlInterest.getValue())+ Number(ctrlRandD.getValue())+ Number(ctrlSalary.getValue())+ Number(ctrlOtherexp.getValue()));

ctrlProfbeftax.setValue(Number(ctrlGrossprof.getValue()) + Number(ctrlOtherinc.getValue()) - Number(ctrlTotalexp.getValue()) );

ctrlProfitafttax.setValue(Number(ctrlProfbeftax.getValue()) - Number(ctrlIncometaxexp.getValue()) );
some of the 130 keypus are:
ctrlRev.on('keyup', func);

ctrlCogs.on('keyup', func);

ctrlAccfees.on('keyup', func);

ctrlDepre.on('keyup', func);
then we have about 5 hide fields (first two per below):
pageObj.hideField("IfdifferentExplanWhy");

var ctrldifferent = Runner.getControl(pageid, 'IsSubjectEntityDifferent');
ctrldifferent.on('change', function(e) {

if (this.getValue() == 'yes') {

pageObj.showField("IfdifferentExplanWhy");

} else {

pageObj.hideField("IfdifferentExplanWhy");

}

});
pageObj.hideField("OtherType");

var ctrlothertype = Runner.getControl(pageid, 'EntityType');
ctrlothertype.on('change', function(e) {

if (this.getValue() == 'Other') {

pageObj.showField("OtherType");

} else {

pageObj.hideField("OtherType");

}

});
Then we have a hide tab function per below
var tabs = pageObj.getTabs();

tabs.hide(0);

tabs.hide(1);

tabs.hide(2);

pageObj.hideField("Whylessthan3prds");
var ctrlperiods = Runner.getControl(pageid, 'TypeofFinancials');
ctrlperiods.on('change', function(e) {

if (this.getValue() == 'three') {

tabs.show(0),tabs.show(1),tabs.show(2),pageObj.hideField("Whylessthan3prds");

}

if (this.getValue() == 'two') {

tabs.show(0),tabs.show(1),tabs.hide(2),pageObj.showField("Whylessthan3prds");

}

if (this.getValue() == 'one') {

tabs.show(0),tabs.hide(1),tabs.hide(2),pageObj.showField("Whylessthan3prds");

}
});