• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
15

What I thought was simple division between two fields is not working

New Here ,
Jan 15, 2024 Jan 15, 2024

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.

TOPICS
JavaScript , PDF forms

Views

91

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 15, 2024 Jan 15, 2024

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.

Votes

Translate

Translate
Community Expert ,
Jan 15, 2024 Jan 15, 2024

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 16, 2024 Jan 16, 2024

Copy link to clipboard

Copied

LATEST

Thank you so much. I would not have been able to have arrived at that script ever. Again, thank you, works like a dream.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines