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

HELP!! I am trying to do a calculation for 4 fields. Two related on line one, two on line two.

Community Beginner ,
Apr 16, 2018 Apr 16, 2018

Copy link to clipboard

Copied

They are exclusive of each other.  What I want is, if a value is entered in field A, make field B = 0 [or blank].  The problem is, if a value if placed in field C, then field B, which is not related go blank.  Why?  there is no other formula for that value.

This is how I have the formula set up in each field.

this.getField("TRADollar").value = "";

this.getField("TRAPct").value = "";

this.getField("Rothdlr").value = "";

this.getField("RothPT").value = "";

The calculation order is correct and listed as follows.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

336

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 , Apr 16, 2018 Apr 16, 2018

Don't use calculations. Use a validation script.

For example the validation script for A would be:

this.getField("TRADollar").value = "";

This will solve your issue. It works like this. The user enters a value into A. When the user hits return or tabs or clicks out of the field the validation script is called, which clears B.  Repeat the pattern for each field.

And I'll repeat this one more time. DO NOT USE A CALCULATION

Votes

Translate

Translate
Community Expert ,
Apr 16, 2018 Apr 16, 2018

Copy link to clipboard

Copied

You didn't add any conditions to your code...

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
Community Beginner ,
Apr 16, 2018 Apr 16, 2018

Copy link to clipboard

Copied

Is the condition applicable on all four fields?  Should I use a, b, c, d for fields to create conditions?  This is not my forte.  I appreciate the feedback.

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
Community Expert ,
Apr 16, 2018 Apr 16, 2018

Copy link to clipboard

Copied

I don't know... It depends on how you want it to work.

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
Community Expert ,
Apr 16, 2018 Apr 16, 2018

Copy link to clipboard

Copied

What is A, B, and C?

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
Community Beginner ,
Apr 16, 2018 Apr 16, 2018

Copy link to clipboard

Copied

those are fields.

If A has a value, then B should be zero or remain blank.

If B has a value, then make A blank

If C has value, then D is blank

if D has value, then make C blank

I had this for the calculation in each field, but if I add a value in C, B becomes blank.  That should not happen.

In field "RothPCT"

this.getField("Rothdlr").value = "";

and so on...

I don't know where the condition should be.

fields.JPG

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
Community Expert ,
Apr 16, 2018 Apr 16, 2018

Copy link to clipboard

Copied

Don't use calculations. Use a validation script.

For example the validation script for A would be:

this.getField("TRADollar").value = "";

This will solve your issue. It works like this. The user enters a value into A. When the user hits return or tabs or clicks out of the field the validation script is called, which clears B.  Repeat the pattern for each field.

And I'll repeat this one more time. DO NOT USE A CALCULATION

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Community Beginner ,
Apr 16, 2018 Apr 16, 2018

Copy link to clipboard

Copied

LATEST

Thanks so much!  That was easy, my favorite kind of answer!  I'm a novice and this is frustrating!  thanks again.

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