I'm fairly new to JavaScript but I'm trying to calculate the difference in hours worked in a fillable PDF form
This is the code ive put together so far. I am running into the error that event.value is NOT a function.
i would appreciate any help to correct the code. This code is for an editable pdf that is in a flowed container. The table has new instance added with the click of a button so the code copies down with each new addition to the table.
Code is Below:
if (this.getField("timeout").valueAsString.length === 0 || this.getField("timein").valueAsString.length === 0) {
event.value = "0";
}
else{
var timefinished = this.getField("timeout").valueAsString.length;
var timestarted = this.getField("timein").valueAsString.length;
var difflnMilliSeconds = Math.abs(timefinished - timestarted )/1000;
// calculate hours
var hours = Math.floor(difflnMilliSeconds / 3600) % 24;
difflnMilliSeconds = hours *3600;
// calculate minutes
var minutes = Math.floor(difflnMilliSeconds / 60) % 60;
difflnMilliSeconds = minutes * 60;
// set field value to the difference
event.value = hours + ":" + minutes;
}