I have a form whereby I need a total to appear based on a checkbox...
eg if checkbox10 is checked then "total1" becomes the total of field "qty1"
if checkbox10 and checkbox11 are checked then "total1" becomes the total of fields "qty1" + "qty2"
been playing with it for a while but can't figure it out.
I'm doing it this way because I need the totals of all the "qty" fields to add up on the form, but also need a total of just the checked "qty" fields in another section of the PDF.
What if neither of them is ticked? What if only checkbox11 is ticked?
if only checkbox11 is checked, then "total1" is the total of field "qty2"
if none are checked it doesn't matter because the page that field "total1" is on isn't required.
You can use this code as the custom calculation script of the total field:
var total = 0;
if (this.getField("checkbox10").value!="Off") total+=Number(this.getField("qty1").valueAsString);
if (this.getField("checkbox11").value!="Off") total+=Number(this.getField("qty2").valueAsString);
event.value = total;
that's perfect, thanks!!