This topic is locked
[SOLVED]

 Calculated values usine JavaScript OnLoad event

6/12/2011 9:23:34 PM
PHPRunner General questions
D
Dave Lowe author

Hi there!
I am trying to calculate the hours worked in a week in a simple timesheet form. Basically adding the hours for Monday, Tuesday etc into a "Total" field. I am using the following code:



function OnPageLoad(pageid)

{

var ctrlMonday = Runner.getControl(pageid, 'Monday');

var ctrlTuesday = Runner.getControl(pageid, 'Tuesday');

var ctrlWednesday = Runner.getControl(pageid, 'Wednesday');

var ctrlThursday = Runner.getControl(pageid, 'Thursday');

var ctrlFriday = Runner.getControl(pageid, 'Friday');

var ctrlSaturday = Runner.getControl(pageid, 'Saturday');

var ctrlSunday = Runner.getControl(pageid, 'Sunday');

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

ctrlTotal.setValue(parseFloat(ctrlMonday.getvalue()) + parseFloat(ctrlTuesday.getValue())+ parseFloat(ctrlWednesday.getValue())+ parseFloat(ctrlThursday.getValue())+ parseFloat(ctrlFridayday.getValue())+ parseFloat(ctrlSaturday.getValue())+ parseFloat(ctrlSunday.getValue()));

};



ctrlMonday.on('keyup', func);

ctrlTuesday.on('keyup', func);

ctrlWednesday.on('keyup', func);

ctrlThursay.on('keyup', func);

ctrlFriay.on('keyup', func);

ctrlSaturday.on('keyup', func);

ctrlSunday.on('keyup', func);


This is inserted into the "JavaScript OnLoad event" for both the "add page" and the "edit page". It does not seem to be working.... Nothing appears in the Total field. I am not sure where to start to find out where the problem is. I am not even sure if the Java actually even loaded. Any suggestions on where to start?
Thanks, Dave.

Sergey Kornilov admin 6/13/2011

I would suggest to check 'How to troubleshoot Javascript errors using Firebug' tutorial at http://xlinesoft.com/phprunner/php-database.htm. If this doesn't help 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.

D
Dave Lowe author 6/13/2011

Thanks Sergey. All typos now fixed.... <GRIN>.... thanks to FireBug and your video tutorial.



I would suggest to check 'How to troubleshoot Javascript errors using Firebug' tutorial at http://xlinesoft.com/phprunner/php-database.htm. If this doesn't help 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.