0 Replies Latest reply on Oct 14, 2014 5:51 PM by liquid One

    Mobile form not calculating on Android Tablet

    liquid One Level 1

      I have a Time Sheet with Javascript that adds the times up, and it works perfect with the PC version of Adobe Reader, but when I try to use it on a nexus 7 tablet the calculations don't work.

      I have tried the official Adobe Reader for Android as well as about a dozen other readers.  If there is a reader that will work with this sheet as is, I don't mind paying for it, or perhaps part of my JavaScript is not supported on mobile, and I can change it with a workaround.

       

      Please Take a look and see what you can see:

      PR_Form_Tablet6.pdf - Google Drive

       

      I have 2 Functions in here:

       

      TimeDiff Function:

      -------------

      function TimeDiff(cStartField, cEndField) {

      var sTimeFormat = 'hh:mm';

      var fDiff = 0;

      // get the start time

      var sStart = this.getField(cStartField).value;

      // get the end time

      var sEnd = this.getField(cEndField).value;

      // complete script only if we have data

      if(sStart != '' & sEnd != '') {

      // convert sStart string to seconds

      var fStart = Time2Num(sTimeFormat, sStart);

      // convert sEnd string to seconds

      var fEnd = Time2Num(sTimeFormat, sEnd);

      // compute difference in seconds

      fDiff += fEnd - fStart;

      }

      return fDiff;

      }

       

       

      Time2Num Function:

      --------------

      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);

      }

       

      And here is a sample field with JavaScript in it:

       

      event.value = '';

      var fDiff = 0;

      /*

      // compute the difference for first pair of fields

      // get the start time

      var sStart = this.getField('Tech_2_Start').value;

      // get the end time

      var sEnd = this.getField('Tech_2_End').value;

      // complete script only if we have data

      if(sStart != '' & sEnd != '') {

      // convert sStart string to seconds

      var fStart = Time2Num('hh:mm', sStart);

      // convert sEnd string to seconds

      var fEnd = Time2Num('hh:mm', sEnd);

      // compute difference in seconds

      fDiff += fEnd - fStart;

      }

      */

       

       

      fDiff = TimeDiff('Tech_2_Start', 'Tech_2_End');

       

       

      // compute and add the difference for the second pair of fields

      /*

      // get the start time

      var sStart = this.getField('Tech_2_Start_2').value;

      // get the end time

      var sEnd = this.getField('Tech_2_End_2').value;

      // complete script only if we have data

      if(sStart != '' & sEnd != '') {

      // convert sStart string to seconds

      var fStart = Time2Num('hh:mm', sStart);

      // convert sEnd string to seconds

      var fEnd = Time2Num('hh:mm', sEnd);

      // compute difference in seconds

      fDiff += fEnd - fStart;

      }

      */

      fDiff += TimeDiff('Tech_2_Start_2', 'Tech_2_End_2');

       

       

      // convert to rounded minutes if not zero

      if (fDiff != 0) {

      fDiff = Math.round(fDiff / 60);

      // report decimal hours

      event.value = fDiff / 60;

      }

       

       

      Thanks,

      Mike