Copy link to clipboard
Copied
Here's the English version of what I'm trying (and failing) to do:
The plain English version of the calculation I’m trying to make for each of the “Total” fields.
Allow value from “c1_w_1”, IF field “camp_1” = “Dougy”
+
Allow value from “c1_w_2”, IF field “camp_2” = “Dougy”
+
Allow value from “c1_w_3”, IF field “camp_3” = “Dougy”
and so on...
It feels as though it needs to be a doc sript and not a field properties script. Below is a graphic to illustrate the functionality I'm trying to recreate in this PDF form.
Any feedback would be greatly appreciated!!!
Copy link to clipboard
Copied
Here's the English version of what I'm trying (and failing) to do:
The plain English version of the calculation I’m trying to make for each of the “Total” fields.
Allow value from “c1_w_1”, IF field “camp_1” = “Dougy”
+
Allow value from “c1_w_2”, IF field “camp_2” = “Dougy”
+
Allow value from “c1_w_3”, IF field “camp_3” = “Dougy”
and so on...
It feels as though it needs to be a doc sript and not a field properties script. Below is a graphic to illustrate the functionality I'm trying to recreate in this PDF form.
Any feedback would be greatly appreciated!!!
Copy link to clipboard
Copied
It can certainly be a field script.
See these tutorials for some help with this:
https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations
Copy link to clipboard
Copied
Thank you for sending those lnks. I read through them and was able to understand what they explain, for the most part) but I'm still running into a brick wall on getting this to work. 😕
Copy link to clipboard
Copied
You can use this code as the custom calculation script of your field:
var total = 0;
if (this.getField("camp_1").valueAsString=="Dougy") total+=Number(this.getField("c1_w_1").valueAsString);
if (this.getField("camp_2").valueAsString=="Dougy") total+=Number(this.getField("c1_w_2").valueAsString);
if (this.getField("camp_3").valueAsString=="Dougy") total+=Number(this.getField("c1_w_3").valueAsString); // etc.
event.value = total;
Copy link to clipboard
Copied
That did it! You're a genious - I had been seeing mention of valueAsString, but did not think it would be the way for me to go at all!!! Thank you so much!