Copy link to clipboard
Copied
Hellos,
I have created a form that I need to implement an If Then statement. Basically if the answer to one field is a "Product" then I need a particular field to return a Value as 10.
Basically If Field A is ProductA Field B=10
If Field A is ProductB then Field B =15
If Field A is ProductC then Field B = 20
Is there a way that this can be incorporated as a formula?
Thank you
Varghese J
Copy link to clipboard
Copied
Sure. You can use this code as the custom calculation script for "Field B":
var fieldA = this.getField("Field A").valueAsString;
if (fieldA=="ProductA") event.value = 10;
else if (fieldA=="ProductB") event.value = 15;
else if (fieldA=="ProductC") event.value = 20;
else event.value = "";
Copy link to clipboard
Copied
Sure. You can use this code as the custom calculation script for "Field B":
var fieldA = this.getField("Field A").valueAsString;
if (fieldA=="ProductA") event.value = 10;
else if (fieldA=="ProductB") event.value = 15;
else if (fieldA=="ProductC") event.value = 20;
else event.value = "";
Copy link to clipboard
Copied
So I have this custom calc to auto populate phone numbers if a certain insurance is selected... but my insurance field is set to allow custom text for third party insurances. How do I add a code to allow for custom text if a custom text is put in the insurance section?
var fieldA = this.getField("Insurance").valueAsString;
if (fieldA=="BCBS Federal") event.value = ("1(800)442-4607");
else if (fieldA=="BCBS TX") event.value = ("1(800)451-0287");
else if (fieldA=="BCBS") event.value = ("1(800)676-2583");
else if (fieldA=="UHC") event.value = ("1(877)842-3210");
else if (fieldA=="Cigna") event.value = ("1(800)244-6224");
else event.value="";
Copy link to clipboard
Copied
The problem with making this field available for manual entry as it is now, is that it's fighting the calculation. Since the value of this field is set from a single source, it is a simple matter to move the script to that source, which means there is no conflict for manual entry. This is your best solution.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Would you by chance know of a tutorial for this? I know pretty much nothing about any of this, but i'm trying. I did get my document to work using the script above, but i would also like my people to be able to enter custom text. However I have no clue now to do it.
Copy link to clipboard
Copied
Here:
https://acrobatusers.com/tutorials/change_another_field/
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Hi! I hope someone might help me.
I have this script but it doesn't seem to run. I have no errors popping up.
The Units field is a drop-down menu.
Script is set up under "Rate" field:
var Units = this.getField("Units").value;
if (Units=="50") event.value = 75;
else if (Units=="100") event.value = 119;
else if (Units=="150") event.value = 125;
else event.value = "False"
I'd like to have $ signs also, but when it didn't work I took them out.
I set the "Units" field to "Commit selected value immediately" under the options.
Copy link to clipboard
Copied
Hi! I hope someone might help me.
I have this script but it doesn't seem to run. I have no errors popping up.
The Units field is a drop-down menu.
Script is set up under "Rate" field:
var Units = this.getField("Units").value;
if (Units=="50") event.value = 75;
else if (Units=="100") event.value = 119;
else if (Units=="150") event.value = 125;
else event.value = "False"
I'd like to have $ signs also, but when it didn't work I took them out.
I set the "Units" field to "Commit selected value immediately" under the options.
I appreciate any advice!
Copy link to clipboard
Copied
Please post this to a new thread and provide more info, such as the exact location of the script. Is it a calcualtion? a format? etc.
Use the Acrobat JavaScript Reference early and often

