JS Problems with overall total, and bugs in timesheet

Community Beginner ,
Apr 26, 2021 Apr 26, 2021

Copied

Everytime i put a value/hours into the form, the overall total keeps on multiplying them, instead of adjusting to what amount of hrs there is actually registered in the form. (See pic for reference).

How can i set it so that the overall total doesn't multiply on itself, but actually represents the amount of total hrs. worked?

I've also got another problem. I've made a Break/subtract function, though it does create certain problems for me as it sets the total value to 24:00 almost every other/2nd time the forms values are adjusted.

Here is my totalTime code which also includes the break code:

``````indice=event.target.name.substr(event.target.name.indexOf(".")+1);
var sStart=this.getField("startingTime."+indice).value;
var sEnd=this.getField("endingTime."+indice).value;
var sBreak=this.getField("BreakRow."+indice).value;

if(sStart != "" & sEnd != "" & sBreak != "") {
var fStart=Time2Num("hh:mm",sStart);
var fEnd=Time2Num("hh:mm",sEnd);
var fBreak=Time2Num ("hh.mm",sBreak);
var fDiff=fEnd-fStart-fBreak;

if (fDiff<0) fDiff=(24*3600)+(fEnd-fStart-fBreak);
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've uploaded my pdf file if you need to take a closer look at it yourself 🙂

TOPICS
How to, JavaScript, PDF forms

Views

67

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 26, 2021 Apr 26, 2021

Copied

LATEST

Check the Javascript console for errors.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources