This topic is locked

Calculate time

1/3/2014 8:12:06 AM
ASPRunnerPro General questions
G
georgweber author

I need urgent help for this:
On add page a have following fields:
Time_start

Time_End

Time
The Value of time_start would be like '10:30' and Time_end like '13:25'
When i entered the Time_end value i need the caluclation between Time_start and Time_end in Hours and minutes and show the result in the time Field on Fly.
Any help please

G
georgweber author 1/8/2014

so this should work?
var ctrlsource1 = Runner.getControl(pageid, 'Acion.');

var ctrlsource2 = Runner.getControl(pageid, 'Corte');

var ctrldiff = Runner.getControl(pageid, 'Tempo');
function func() {
ctrldiff.setValue(datediff("n",ctrlsource2.getValue(),ctrlsource1.getValue()))

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

G
gonzalosb 1/8/2014



so this should work?
var ctrlsource1 = Runner.getControl(pageid, 'Acion.');

var ctrlsource2 = Runner.getControl(pageid, 'Corte');

var ctrldiff = Runner.getControl(pageid, 'Tempo');
function func() {
ctrldiff.setValue(datediff("n",ctrlsource2.getValue(),ctrlsource1.getValue()))

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



every VAR function need to be close exept for the total VAR "ctrldiff" at the end, so should be:



ctrlsource1.on('keyup', func);

ctrlsource2.on('keyup', func);



if you add more "ctrlsource 3, 4, 5, etc" VAR need to be close at the end too.

and try replace total line function with this one and see what happen:



ctrldiff.setValue(date(ctrlsource2.getValue() / (date(ctrlsource2.getValue())


at the end is ";}" , not "};"

look here an example:How to calculate values on the fly

G
georgweber author 1/9/2014

Ok, Thank you. I have changed this. Now it´s look like this
var ctrlsource1 = Runner.getControl(pageid, 'Acion.');

var ctrlsource2 = Runner.getControl(pageid, 'Corte');

var ctrldiff = Runner.getControl(pageid, 'Tempo');
function func() {
ctrldiff.setValue(date(ctrlsource2.getValue() / (date(ctrlsource1.getValue()))))

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

ctrlsource2.on('keyup', func);
But dosn't work. The error is "'date' not defined"

admin 1/9/2014

There is such function as date() in Javascript and this is why it says "'date' not defined"