This topic is locked

javascript onload even

12/26/2012 2:38:54 AM
ASPRunnerPro General questions
A
adnankmk author

I have the following table
table name employee
fields
emp_appDate

emp_Dateofbirth

emp_RetirementDate
I want to use the event on the Report and the function should calculate the years of retirement left when the Report Page is loaded. When I execute the report the Status of page remains loading. How I should resolve this.
I used the following function
var birth = Runner.getControl(pageid, 'emp_Dateofbirth');

var app = Runner.getControl(pageid, 'emp_appDate');

var retire = Runner.getControl(pageid, 'emp_RetirementDate');
function func() {

var now = new Date();

var dateofbirth=new Date(birth.getValue());

var dobyear=dateofbirth.getFullYear();

var yearofapp=new Date(app.getValue());

var appyear=yearofapp.getFullYear();

var YearNow = now.getFullYear();

var ageinyears=YearNow-dobyear;

var yearserved=YearNow-appyear;
if (ageinyears>=60||yearserved>=25)

var leftservice = 0;

else

{

var leftservice = yearsleft();

}

function yearsleft()

{

var a = 60-ageinyears;

var bc = 25-yearserved;
if (a>bc)

return (a);

else

return (bc);

}
retire.setValue(leftservice);

};
retire.on('load', func);
// Place event code here.

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

Sergey Kornilov admin 12/26/2012

I guess there is some sort of Javascript error in your code. I recommend to check this article that can help you troubleshoot Javascript errors:

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

A
adnankmk author 12/27/2012



I guess there is some sort of Javascript error in your code. I recommend to check this article that can help you troubleshoot Javascript errors:

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


Thanks for responding.

I used the same event on the add page and it works perfectly. The page may remains in loading form when I use this in the report.

Sergey Kornilov admin 12/27/2012

I'm not sure I understand how do you want us to help.
If there are Javascript errors - you need to troubleshoot them to find what exactly is wrong. This article can help:

http://xlinesoft.com/blog/2012/05/22/how-to-troubleshoot-javascript-errors/
If you have a valid support contract post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.