Skip to main content
Participating Frequently
February 2, 2016
Answered

Populate field based on data entered in another field

  • February 2, 2016
  • 2 replies
  • 883 views

I'm working on a document that will have benefit plan pricing levels at the top. In the column below there are individual fields for each of the various benefit options. The co-pay cost for these options will depend on what the monthly contribution is which is the value entered at the top.

Assuming my range of monthly contributions are $100, $125 & $150 I'm looking for a script that I can customize for each subsequent field that would, I'm assuming do the following:

  • Get the value from the primary field "PlanBenefit01":
    • If value in PlanBenefit01 is "$100" enter "XXX" in the field
    • If value in PlanBenefit01 is "$125" enter "YYY" in the field
    • If value in PlanBenefit01 is "$150" enter "ZZZ" in the field

I'm assuming that this would be entered in the "Properties>Calculate>Custom Calculation Script" section for the field as another recent solution was. If so please confirm. If not, kindly provide me with guidance on where to insert this?

Thanks again to one and all.

This topic has been closed for replies.
Correct answer try67

Assuming they are actually numbers, without the "$" symbols, you can use this code as the custom calculation script of your field:

var plan = Number(this.getField("PlanBenefit01").value);

if (plan==100) event.value = "XXX";

else if (plan==125) event.value = "YYY";

else if (plan==150) event.value = "ZZZ";

else event.value = "";

2 replies

Participating Frequently
February 4, 2016

Thank you yet again!

Yes, originally the text entered as the dollar symbol but I could sense where you were going with that so I changed that field to be formatted. No when the user enters the number it populates the correct amount.

Thanks again!

try67
Community Expert
Community Expert
February 2, 2016

Yes, it needs to be a custom calculation script. Is the value of "PlanBenefit01" a number with the currency symbol added to it through the Format settings, or does its actual value include that symbol?

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
February 2, 2016

Assuming they are actually numbers, without the "$" symbols, you can use this code as the custom calculation script of your field:

var plan = Number(this.getField("PlanBenefit01").value);

if (plan==100) event.value = "XXX";

else if (plan==125) event.value = "YYY";

else if (plan==150) event.value = "ZZZ";

else event.value = "";

Participating Frequently
February 9, 2016

Hi again.

Figured I would reach out to you since you've been the go to guy thus far.

Below is a sample of what I'm using in one of my fields:

var plan = Number(this.getField("OPPAOption1").value);

if (plan==100) event.value = "\$100";

else if (plan==125) event.value = "\$125";

else if (plan==150) event.value = "\$150";

else if (plan==200) event.value = "\$200";

else event.value = "";

Is it possible to alter this so that data can be manually entered as well?

Thanks again!