Skip to main content
Participant
April 16, 2018
Answered

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

  • April 16, 2018
  • 2 replies
  • 759 views

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.

This topic has been closed for replies.
Correct answer Thom Parker

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

2 replies

Bernd Alheit
Community Expert
Community Expert
April 16, 2018

What is A, B, and C?

md29nycAuthor
Participant
April 16, 2018

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.

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
April 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

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
April 16, 2018

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

md29nycAuthor
Participant
April 16, 2018

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.

try67
Community Expert
Community Expert
April 16, 2018

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