Copy link to clipboard
Copied
Field name: box1, box2, box3, box4, box5
All of the above are check boxes,
Box6 is a total from another field
Now i need a conditional script for box7 if box1 and box2 is checked
Substract 20 from box6 and if box3 and box4 is checked substract 45 from box6
and if box5 is checked substract 10 from box6 or else leave blank
Thanks!!!!
Copy link to clipboard
Copied
You do this with a custom calculation script for "box7" that checks the state of the checkboxes:
var b1 = this.getField("box1").value != "Off";
var b2 = this.getField("box2").value != "Off";
var b3 = this.getField("box3").value != "Off";
var b4 = this.getField("box4").value != "Off";
var b5 = this.getField("box5").value != "Off";
var v = this.getField("box6").value;
if (b1 && b2) {
event.value = v - 20;
}
else if (b3 && b4) {
event.value = v - 45;
}
else if (b5) {
event.value = v - 10;
}
else {
event.value = "";
}
This does not take into account the case where e.g. all five boxes are chexed. I will leave that up to you to implment that and any error checking (e.g. what happens if there is no numeric value in box6).
Copy link to clipboard
Copied
It works thanks!!!