Copy link to clipboard
Copied
Hello ladies and gentlefolks!
I have a form in which a section of it utilizes numbers - both negative and positive numbers. The options are set to change negative numbers to be red and in parenthesis. I also created an additional field - but what I need for it to do is to only take the numbers that are of a negative value and add only those negative values together (ignoring thje positive or zeros) to give me a grand (negative) total. I use Acrobat Pro DC (not sure if this all of the information that is needed).
Thank you so much in advance.
You can use this code as the custom calculation script of the field that should display the total owed amount:
var total = 0;
for (var i=1; i<=16; i++) {
var v = Number(this.getField("R"+i+"B").valueAsString);
if (v<0) total+=v;
}
event.value = total;
Copy link to clipboard
Copied
I guess I could have attached a screenshot.... Here is more of what I am trying to do...
All of the fields labeled as "RxB" will have the numbers in the (either a positive or a negative)
The "Total Owed" field should only be calculating all of the negative numbers from the "RxB" fields.
I hope this clarifies and that my attachment uploaded correct (new MacBook)
Copy link to clipboard
Copied
You can use this code as the custom calculation script of the field that should display the total owed amount:
var total = 0;
for (var i=1; i<=16; i++) {
var v = Number(this.getField("R"+i+"B").valueAsString);
if (v<0) total+=v;
}
event.value = total;
Copy link to clipboard
Copied
That works flawlessly! Thank you! You're a genious - I have used many of your suggestions as I am learning all of this!
Thank you so much!