This topic is locked

Timediff on the fly

1/22/2015 5:13:31 AM
ASPRunnerPro General questions
J
jackolantern author

Hello, does anybody have solution to make this code work, i dunno what wrong with my code.

I want to calculate between 2 date and time to calculate time diff between two and saved it in PlanDuration.
Below is the javascript code (Javascript OnLoad Event).



var cPlanStartDate = Runner.getControl(pageid, 'PlanStartDate');

var cPlanStartTime = Runner.getControl(pageid, 'PlanStartTime');

var cPlanFinishDate = Runner.getControl(pageid, 'PlanFinishDate');

var cPlanFinishTime = Runner.getControl(pageid, 'PlanFinishTime');

var cPlanDuration = Runner.getControl(pageid, 'PlanDuration');
function func() {

var time1=Date(cPlanStartDate.getValue()+" "+cPlanStartTime.getValue());

var time2=Date(cPlanFinishDate.getValue()+" "+cPlanFinishTime.getValue());

cPlanDuration.setValue(Number((time2.getTime()-time1.getTime())/3600));

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

cPlanStartTime.on('keyup', func);

cPlanFinishDate.on('keyup', func);

cPlanFinishTime.on('keyup', func);

cPlanDuration.on('keyup', func);

cPlanStartDate.on('change', func);

cPlanStartTime.on('change', func);

cPlanFinishDate.on('change', func);

cPlanFinishTime.on('change', func);
admin 2/12/2015

fajar,
unfortunately I don't know what's wrong with this code. The general troubleshooting idea is to step through the code, inspect value of each variable on each step to find what exactly goes wrong.
You can find more tips at https://developer.chrome.com/devtools/docs/javascript-debugging