• Global community
• Language:
• Deutsch
• English
• EspaÃ±ol
• FranÃ§ais
• PortuguÃªs
• æ—¥æœ¬èªžã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£
Dedicated community for Japanese speakers
• í•œêµ­ ì»¤ë®¤ë‹ˆí‹°
Dedicated community for Korean speakers
Exit
• Help! Javascript calculated fields and coded butto...

# Help! Javascript calculated fields and coded buttons do not function in android Adobe Reader.

New Here ,
Mar 25, 2019 Mar 25, 2019

Copied

I have a job crew form that I have pretty much automated to save myself some time at the end of a job. And as a major part of this improvement my only option known to me to handle in/out time calculations using JavaScript to create a function [Time2Min] to convert the times to calculable values inside the function [TimeDiff] that performs the time difference operation. The code is below:

function Round(nValue, nPrecision) {

// round a number a given precision

return util.printf("%,101." + nPrecision + "f", nValue);

} // end round

function Time2Min(cFormat, sTime) {

sTime = sTime.toLowerCase();

if( (cFormat == "h:MM tt" || cFormat == "hh:MM tt") && ( (sTime.substr(0, 2) == "12" && sTime.substr(6,1) == 'a') || (sTime.substr(0, 2) == "12" && sTime.substr(5,1) == 'a') ) )

sTime = "00" + sTime.substr(2, sTime.length - 2);

// convert a formatted time string to number of minutes since midnight

// get time object

var oTime = util.scand("mm/dd/yyyy " + cFormat, "01/01/1970 " + sTime);

// convert to milliseconds

var nTime = oTime.getTime();

// convert to milliseconds to minutes and return value

nTime = nTime / (1000 * 60);

// return round to whole minutes

return Number(Round(nTime, 0));

} // end Time2Min

function TimeDiff(cFormat, cTimeIn, cTimeOut) {

var nDiff = 0;

// get the value of the time in and out fields

var sOut = this.getField(cTimeOut).value;

var sIn = this.getField(cTimeIn).value;

// compute if we have both values

if(sOut != "" && sIn != "") {

// convert time string to minutes and compute difference

nDiff = Time2Min(cFormat, sOut) - Time2Min(cFormat, sIn);

// convert to hours

nDiff = nDiff / 60;

}   // end if sOut & sIn

// return rounded value

return Round(nDiff, 2);

}

TOPICS
Acrobat SDK and JavaScript , Windows

Views

254

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Mar 26, 2019 Mar 26, 2019

Copied

LATEST

Why? What's wrong with what you have?