Hi Guys,
I have a nice little piece of JS that calculates how many days a patient has been in hospital for.
I takes a date admitted and compares it to today's date to calculate how many days a patient is in hospital.
It fires really well with the admission date field on('change') event.
The problem I'm having is the day calculation is only updated if the user changes the actual date of admission.
I really would love to have a dynamic day count calculation updated each time a user loads the page without having to touch anything!
I have have some success in the past using setInterval but this time I can't get it to fire automatically.
Also tried the window.onload ( function(){ with no luck also
Any ideas would be very much appreciated.
Many thanks
J
var ctrDayDate1 = Runner.getControl(pageid, 'admission_Date');
var ctrDayRem1 = Runner.getControl(pageid, 'total_Days_Admitted');
setInterval("setDates1()", 300);
function setDates1() {
if (ctrDayDate1.getValue()) {
var ddate1 = new Date(ctrDayDate1.getValue());
ddate1.setDate(ddate1.getDate());
var out1 = (ddate1.getMonth() + 1) + "/" + ddate1.getDate() + "/" + ddate1.getFullYear();
//ctrDayExp.setValue(out);
var currDate1 = new Date();
var cDate1 = currDate1.getTime();
var eDate1 = ddate1.getTime();
ctrDayRem1.setValue(parseInt((cDate1 - eDate1) / 1000 / 60 / 60 / 24) + 1);
}
}
//});