Copy link to clipboard
Copied
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:
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.
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 = "";
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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 = "";
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
It's possible, but it's a bit tricky. It would require moving the code from the custom calculation script of this field to the custom validation script of the other one (OPPAOption1, in this case), and adjusting it a bit.
Also, you should remove the back-slash before the dollar symbol in your code.
Copy link to clipboard
Copied
Thanks.
I thought I needed the "\" in order to show the $ sign. I realized that as some fields have either dollar value or text responses I couldn't use the formatting option as I received an error message on those fields.
Any guidance on how to go about changing the script to function properly so that either a default value is given based on one of the 4 pre-determined options or give the user an option to manually enter data?
Thanks again!
Copy link to clipboard
Copied
Just want to let you know that I figured it out.
var ro = true;
var plan = Number(this.getField("fieldValueName").value);
if (plan==100)
event.value = "WWW";
else if (plan==125)
event.value = "XXX";
else if (plan==150)
event.value = "YYY";
else if (plan==200)
event.value = "ZZZ";
else {
event.value = "";
ro = false;
}
event.target.readonly = ro;
Works like a charm.
Copy link to clipboard
Copied
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!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now