Skip to main content
Participating Frequently
April 7, 2021
Question

JavaScript to Sum multiple fields

  • April 7, 2021
  • 1 reply
  • 7100 views

Hi everyone.  Needing help with a script.

 

I would like for my timesheet to total the hours worked (Regular Hours + Sick Hours) ONLY if there is information in the date field, and if not leave the total hours blank (maybe they don't work on Mondays for instance).  I know in Excel it would be =IF(Date>0,Reg Hrs + Sick Hrs,"").  Any help is greatly appreciated.  Thanks.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
April 8, 2021

Date and time calculations in Acrobat JS are not trivial. Do you have any experience with writing scripts for PDF files?

You can try searching these forums, as this issue was discussed many times in the past and there are some code examples and tutorials on the subject. Making the result dependent on the value of another field is actually the easy part...

Participating Frequently
April 12, 2021

Unfortunately, I have no experience with it.  I've tried to follow the logic and tried to search for how to write script but I guess my brain just won't compute.  I've also tried searching the forums for how to accomplish what I am trying to do but can't seem to find the exact answer.  I will try searching again.  Thanks.

Inspiring
April 12, 2021

File attached.  I want the Total Hours to add Regular Hours + Sick Hours only if there is a date on that line...otherwise I would like it to remain blank.  Does that help?  Thank you so much for your help.


You input hours with decimal, like this 10.00 or just 10? and 8.35 you use decimal?