Javascript - Subtracting from a total field
Hi Community
I'm in a bit of a pickle with a subtract function in my pdf form.
I need to make a piece of subtraction code that subtracts break time from a total time.

This is the form i'm working on.
This is the code snipped i'm working on. It is taken from the field totalTime.1
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;
}
This is one of the solutions i've tried thus far, though to no avail. I've also tried to create the subtraction as a seperate if statement below the fDiff if statement, though i'm afraid that i lack the skills to spot where i go wrong. Can anybody help me 🙂
