FORM CALCULATIONS: multiplying 2 fields with a fixed number
Copy link to clipboard
Copied
Thanks for any insight.
Mary
Copy link to clipboard
Copied
// Get first field value, as a number
var v1 = +getField("Text1").value;
// Get second field value, as a number
var v2 = +getField("Text2").value;
// Calculate and set this field's value to the result
event.value = 2 * (v1 + v2);
Be sure to set any calculated fields to read-only so the user can't attempt to interact this them.
George
Copy link to clipboard
Copied
I don't want to be bothered with having to enter thru this pesky message 3 times so i'm trying to resolve it.
Each of the three fields calculate from other input on the form. The only way i don't get the pesky error that pops up, is to set the Format Catetory for each of this fields to NONE. But then the number is NaN or infinity until the form is filled out, and the result is a really long number. I have tried to change this to simply, Number, with 2 decimals.
Any insight to this? i've tried every way i can think of....
thanks
mary
Copy link to clipboard
Copied
George
Copy link to clipboard
Copied
Field A is data input. (ypp)
Field B is the sum calculated by other fields. (totalwarpyards)
Field C is the sum calculated by other fields. (totalweftyard)
Field D is the sum addition of B & C. ( totalwarpyards, totalweftyards )
Field E is the calculated sum amount of Field D, then divided by A. (warpweftyardage/ypp)
seems pretty straight forward, but if i change the Format to be anything but NONE, i get that pesky error message (although it works properly. weird huh?)
thanks so much for giving me so much help!
mary
Copy link to clipboard
Copied
George
Copy link to clipboard
Copied
the last 3 fields (all under the Letter Z are my problem children)
thanks.
mary
Copy link to clipboard
Copied
Below is a script you can use as the custom calculation script for the "lbsandounces" field:
(function () {
// Get the field values, as numbers
var wwy = +getField("warpweftyardage").value;
var ypp = +getField("ypp").value;
// Perform calculation and set this field value to result
if (ypp !== 0) {
event.value = wwy / ypp;
} else {
// If ypp = 0, blank this field
event.value = "";
}
})();
You'd do something similar for the other two fields, but specify the correct field names.
George
Copy link to clipboard
Copied
Thank you so much for taking the time to help me. The code you so generously gave me worked perfectlly. Thanks so much for the help - my little form works brilliantly for my needs! finally and without all those pesky little errors!
Thanks again.
Mary
Copy link to clipboard
Copied
Thanks very much -
Mary
Copy link to clipboard
Copied
I also noticed that the calculation for the (C) field is causing an error. If you change it to be the Sum of "how_wide_is_the_project_in_nches", it should be OK.
Also, is it "fringe" or "finge", or both? I see both spellings.
George
Copy link to clipboard
Copied
Thanks again for all your help.
Mary
Copy link to clipboard
Copied
I am using Acrobat 9 Pro Extended. I am working on a form that allows you to enter Income amounts for Hospital Charity Care program.
What I want to do is the following:
#1 Add these 9 fields together- (Welfare,Soc Sec,VA Pension,Text15,Text16,Text17,Text18,Text19,Last 1 month) and then multiply by 12
#2 There is a field named "Last 3 Months" I want to multiply that by 4(the catch is I don't want the total displayed on the field)
#3 I want to add The total of #1, #2 and a field named "Annualized"
The total of all of this would go onto a field names "Last 12 Months"
I want to write the script to do all these calculations on the "Last 12 Month" field
I've tried different methods but it doesn't seem to calculate automatically as I change the numbers.
Please help!
Copy link to clipboard
Copied
If you send me an email and include your form, I'll see what I can do.
George
Copy link to clipboard
Copied
(function () {
// Get alll of the field values, as numbers
var v1 = +getField("Welfare").value;
var v2 = +getField("Soc Sec").value;
var v3 = +getField("VA Pension").value;
var v4 = +getField("Text15").value;
var v5 = +getField("Text16").value;
var v6 = +getField("Text17").value;
var v7 = +getField("Text18").value;
var v8 = +getField("Text19").value;
var v9 = +getField("Last3Months").value;
var v10 = +getField("Annualized").value;
// Calculate the result and set this field value
event.value = 12 * (v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8) + (4 * v9) + v10;
})();
George
Copy link to clipboard
Copied
None of this makes sense to me. I figured if I double clicked the field where I want the product to go and specified which forms to multiply it would calculate. I can't be putting in all those formulas.
Copy link to clipboard
Copied
Can you explain exactly what you need?
If you have simple calculations, you can go to 'Calculate' tab of 'Total' field select 'Value is the' then select 'product(x)' (for multiply) and then 'Pick' to select which fields you wish to multiply, for little more advanced calculations you can use 'Simplified field notation' (also under 'Calculate' tab) where you enter formulas using field names, for example: field1*field2 or field1*field2+field3...etc (it's best to use field names without spaces in their names).
For more advanced calculations, you would need custom calculation script.

