Copy link to clipboard
Copied
I am hopeless with the abstract e.g. programming.
Using Acrobat Forms I wish to divide one text field into another. One field is a result of a calculation of user entries, the other will be a number entered by the user.
Reading posts I see this cannot be done by simple field notation (Text 7)/Text 11. I tried several variations.
Reading the not so simple calculations help page I arrived at the following formula in my target field (Text12) which I think is close but not quite correct.
event.value = ( this.getField("Text7"). value/ this.getField("Text11")).value;
but this does not work. A value remains in the target field Text12 from previous attemps but does not change and is also incorrect if I calculate longhand.
Any assistance greatly appreciated.
This is not confidential so happy to post the whole thing; it's to help plumbers calculate a flow rate and pipesize.
Copy link to clipboard
Copied
You can use this script:
var t7 = Number(this.getField("Text7").valueAsString);
var t11 = Number(this.getField("Text11").valueAsString);
if(t11 === 0)
event.value = "";
else
event.value = t7/t11;
If it doesn't calculate correctly, you need to change field calculation order by selecting 'Prepare form' tool, clicking on 'More' and then 'Set field calculation order', fields that calculate first should be on top.
Copy link to clipboard
Copied
You can use this script:
var t7 = Number(this.getField("Text7").valueAsString);
var t11 = Number(this.getField("Text11").valueAsString);
if(t11 === 0)
event.value = "";
else
event.value = t7/t11;
If it doesn't calculate correctly, you need to change field calculation order by selecting 'Prepare form' tool, clicking on 'More' and then 'Set field calculation order', fields that calculate first should be on top.
Copy link to clipboard
Copied
Thank you so much. I would not have been able to have arrived at that script ever. Again, thank you, works like a dream.
Copy link to clipboard
Copied
Thank you! I've never worked with Java before, but this made perfect sense and really helped.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now