Copy link to clipboard
Copied
Hello,
I don't know too much involving Javascript. I have done a couple small items but nothing past what you consider "beginner". I was wondering if someone could help me with what I have below:
I have 2 columns. Column 1 contains text boxes that are labeled as "TQ1" through "TQ10". Column 2 contains drop downs labeled "DN1" through "DN2". I have 2 more text boxes on the pdf labeled "TotalD" and "TotalN". What I would like to do is this: If "D" is selected in the drop down and 8 is put as the value for "TQ", then I would like that value added to the "TotalD" box. If "N" is selected in the drop down and 8 is the value, the I would like that value added to the "TotalN" box. I'd like to be able to do this for all rows (1-10). The values entered into the "TQ" boxes would be added together and the total would be put into the "TotalD" or "TotalN" boxes depending on what option they choose in the drop downs.
Thank you in advance for your help! I hope I made everything clear enough to find a solution.
Thanks!
Copy link to clipboard
Copied
In one of the field as custom calculation script use this:
var d = 0;
var n = 0;
for( var i=1; i<=10; i++){
if(this.getField("TQ"+i).valueAsString == "8" && this.getField("DN"+i).valueAsString == "D")d+=8;
if(this.getField("TQ"+i).valueAsString == "8" && this.getField("DN"+i).valueAsString == "N")n+=8;}
this.getField("TotalD").value = d;
this.getField("TotalN").value = n;