Copy link to clipboard
Copied
Using Acrobat Pro, I have a dropdown field called Program. User will select from three options
I then have Textbox field that is called programLong. I want this field to auto update to the long names for each or be blank if option 1 is not changed.
Here is my code that will only update the programLong filed if I preview and then click Edit. It will not update when the dropdown field changes values.
var progValue = this.getField("Program").value;
if (progValue == "SNAP") {
event.value = "Supplemental Nutrition Assistance Program (SNAP)";
}
else if (progValue == "TANF"){
event.value = "Temporary Assistance for Needy Families (TANF)";
}
else if (progValue == "Choose One"){
event.value ="";
}
Copy link to clipboard
Copied
+++EDITED REPLY... I made a mistake
Hi there @David38818339zr2v ,
Here is a working example using Acrobat's built-in features and one line of code employed as a Custom Calculating Script: https://acrobat.adobe.com/id/urn:aaid:sc:US:df02540b-5841-436a-963f-8d0cad6a5eab
In this particular example, I am assuming that the users will not be able to type in any data in the "programLong field. In which case, you can keep that textfield as readonly. Therefore, I am assigning to each item of the dropdown menu the long answer as the export value (illustrated in my screenshot below).
The Custom Calculating Script Script that I am using on "programLong" textfield :
var progValue = this.getField("Program").value;
(progValue == "Choose One")? event.value =="" : event.value = progValue
The script will execute as soon as the selection is commited in the dropdown field "Program", populating the "programLong" textfield with the desired long answer (export value).
See screenshot:
Copy link to clipboard
Copied
I have tried to place this script on a the calculated field on Program and programLong fields with no success.
Copy link to clipboard
Copied
+++EDITED REPLY... I made a mistake
Hi there @David38818339zr2v ,
Here is a working example using Acrobat's built-in features and one line of code employed as a Custom Calculating Script: https://acrobat.adobe.com/id/urn:aaid:sc:US:df02540b-5841-436a-963f-8d0cad6a5eab
In this particular example, I am assuming that the users will not be able to type in any data in the "programLong field. In which case, you can keep that textfield as readonly. Therefore, I am assigning to each item of the dropdown menu the long answer as the export value (illustrated in my screenshot below).
The Custom Calculating Script Script that I am using on "programLong" textfield :
var progValue = this.getField("Program").value;
(progValue == "Choose One")? event.value =="" : event.value = progValue
The script will execute as soon as the selection is commited in the dropdown field "Program", populating the "programLong" textfield with the desired long answer (export value).
See screenshot:
Copy link to clipboard
Copied
Nice and simply, I love it! Better than what I was trying to use.
Copy link to clipboard
Copied
It won't work in the Program field because you are using event.value. It should work in the programLong field as a custom calculation script. If you are going to use it in the Program field it would be a validation script, but you have to change this.getField("Program").value to event.value and change all event.value's to this.getField("programLong").value. Also select "Commit selected value immediately" in the options tab of the dropdown. These two articles explain calculation vs validation scripts:
https://pdfautomationstation.substack.com/p/calculation-vs-validation-scripts
https://pdfautomationstation.substack.com/p/calculation-vs-validation-scripts-eb5
There is an easier way though:
1) Set the corresponding export values of "SNAP" and "TANF" to the long versions.
2) Enter the following custom calculation script in the programLong field:
event.value=(this.getField("Program").value=="Choose One")?"":this.getField("Program").value;
Copy link to clipboard
Copied
Nice and simply, I love it! Better than what I was trying to use.
Copy link to clipboard
Copied
You can also use:
event.value=this.getField("Program").value;
But you have to set the export value of Choose One to null and that can only be done with a script or a tool like this one I developed (paid for).
Copy link to clipboard
Copied
There is another way, one I am not fond of, but I used a single space. Not one that I would normally encourage, but it works for our purpose.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more