• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to create Javascript for time sheet

Explorer ,
May 16, 2018 May 16, 2018

Copy link to clipboard

Copied

Good evening,

I need help with the below table. Is there a simple script to total the time in an adobe acrobat form?

Thank you in advance for your help.

TOPICS
Acrobat SDK and JavaScript

Views

1.5K

Translate

Translate

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 guidelines
Community Expert ,
May 16, 2018 May 16, 2018

Copy link to clipboard

Copied

Votes

Translate

Translate

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 guidelines
Engaged ,
May 17, 2018 May 17, 2018

Copy link to clipboard

Copied

LATEST

Got excatly the time sheets at work.

I named my fields that way ->  ADM034.TABLE.number.number

numbers are replaced by the y/x position of the cell as if it was a table in excel.  The first number being the row (y) and the last number being the column (x).  Numbers are 0-based.

ADM034.TABLE.0.0     ADM034.TABLE.0.1     ADM034.TABLE.0.2

ADM034.TABLE.1.0     ADM034.TABLE.1.1     ADM034.TABLE.1.2

ADM034.TABLE.2.0     ADM034.TABLE.2.1     ADM034.TABLE.2.2

etc

Then put the same script in the calculate event of the total field.  (You should pass it as a doc level function but you don't have to)

var myName = event.target.name

var aName = myName.split(".")

var myLine = Number(aName[2])

var myColumn = Number(aName[3])

//gather the values

var SstartValue = this.getField("ADM034.TABLE."+myLine+"."+(myColumn-2)).valueAsString

var SstartTime = SstartValue.substr(0, 2)+":"+SstartValue.substr(2)

var SendValue = this.getField("ADM034.TABLE."+myLine+"."+(myColumn-1)).valueAsString

var SendTime = SendValue.substr(0, 2)+":"+SendValue.substr(2)

if ((SstartValue != "")&&(SendValue != "")){

//convert to date object

var OstartTime = util.scand("yyyy-mm-dd HH:mm", "2018-01-01 "+SstartTime)

var OendTime = util.scand("yyyy-mm-dd HH:mm", "2018-01-01 "+SendTime)

//convert to milliseconds

var milStart = OstartTime.valueOf()

var milEnd = OendTime.valueOf()

//End time update

if (milStart > milEnd) milEnd += 1000*60*60*24

event.value = (milEnd-milStart)/(1000*60*60)

}

else event.value = ""

Votes

Translate

Translate

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 guidelines