We have used the form Brake log sheet I created in Adobe Acrobat XI Pro with the current JavaScript to subtract time and it works fine. I am still trying to learn JavaScript language so please be patient with me. I would like to create the form in designer but need to get the script working. I imported the Acrobat form into Designer for the time being and as i have read you will have to correct some of the JavaScript but when i run it I receive no errors and it does not work so i do not know were to start working. I would like someone to take a look at it and please help me on it.
I don't see a way to attach my PDF so ill insert the code i have.
Under Variables
function Num2sTime
function sTime2Num
function SupressZero
function Time2Num
Num2sTime function Num2sTime(fValue) { // convert minutes to HH:MM string fDiff = Math.round(Number(fValue) / 60); // get hours from fDiff fHours = Math.floor(fDiff / 60); // get minutes less than hour from fDiff fMins = Math.round(((fDiff / 60) - fHours ) * 60); // format fMins with leading zero sMins = util.printf("%,302.0f", fMins); // build display string return fHours + ':' + sMins; } SupressZero function SupressZero(sValue) { if(Number(sValue) ==0) sValue = ''; return sValue; } Time2Num function Time2Num(sFormat, sTime) { /* convert time string (sTime) with format of sFormat to the seconds since the start of the day */ if(sTime == '') return ''; // exit // get date time for Epoch date and sTime var oTime = util.scand('mm/dd/yyyy ' + sFormat, '01/01/1970 ' + sTime); // convert UTC Offset to milliseonds for adjustment var fTZOffset = oTime.getTimezoneOffset() * 1000 * 60 // time since the start of the day in millseconds var fTime = oTime.valueOf() - fTZOffset; // convert to seconds and return value return Math.round(fTime / 1000); } sTime2Num function sTime2Num(sValue) { if(sValue == '') return 0; var aValue = sValue.split(':'); return (aValue[0] * 3600) + (aValue[1] * 60); }
and in my calculate script were i place in the text Field Total_TimeRow1
event.value = ''; var sStart = this.getField('Time OutRow1').value; var sEnd = this.getField('Time InRow1').value; if(sStart != '' & sEnd != '') { var fStart = Time2Num('HH:MM', sStart); var fEnd = Time2Num('HH:MM', sEnd); var fEnd = Time2Num('HH:MM', sEnd); var fDiff = fEnd - fStart; fDiff = Math.round(fDiff / 60); fHours = Math.floor(fDiff / 60); fMins = ((fDiff / 60) - fHours ) * 60; sMins = util.printf("%,302.0f", fMins); event.value = fHours + ':' + sMins; }
I'll insert the pdf is someone can tell me how.
Thank you all for your help in this matter.