I can't get my calculations to work depending on whether the check box is check or not.
If someone checks the check box, I want the amount of kms collected and totaled at the bottom. If the check mark is not checked, do not grab the number of kms in that line. I just learned JS in the last week in order to make this calculation work on a fillable PDF...so excuse my lack of knowledge and/or background!! I have got it to add up the amounts before, but it didn't work if I unchecked a box and didn't work when I started to add more lines. It seemed to not like when the check array returns a NULL. Currently, it won't add anything and it's returning a zero. Can anyone see where I have gone wrong in the code below? Thanks!
var check = ["Check.1", "Check.2", "Check.3"];
var km = ["KMsRow1", "KMsRow2", "KMsRow3"];
function myKM()
{var KM = 0;
var i = 0;
var c = 0;
for (i = 0; i < 20; i++)
{if(this.getField(check) == 1)
{KM.value += this.getField(km);
event.value = parseFloat(KM);}
else
{event.value = parseFloat(KM);}}}
myKM(km, check);
