Copy link to clipboard
Copied
Description:
Hello members of the Adobe community,
I'm running into a puzzling issue when trying to create independent copies of dropdown lists and text fields in a project. I would like to share my situation and ask for help in finding a solution.
Context:
Within my project, I have a dropdown called "EPI DESCRIPTION.0", which contains a variety of Personal Protective Equipment (EPI). When I select a specific item from this drop-down list, I want the text field "CA.0" to auto-populate with the corresponding value of the Certificate of Approval (CA) for that PPE.
To make the process more organized, I created copies of the dropdown lists and text fields, renaming them to "EPI.1 DESCRIPTION" and "CA.1" respectively. The idea is that these copies are independent of the originals.
The problem:
However, when selecting an item from the "EPI.1 DESCRIPTION" drop-down list, the resulting value is displayed in the "CA.0" text field instead of appearing in the "CA.1" field. It seems the copies are not working independently as intended.
Help Request:
I'm looking for guidance on how to fix this issue and make the copies of dropdowns and text fields truly independent. I need to ensure that when choosing an item from the "EPI.1 DESCRIPTION" list, the associated value is displayed in the "CA.1" field.
Thank you in advance for any help, suggestions or solutions you can offer me. Your expertise will be very valuable to resolve this obstacle and move forward with my project.
Yours sincerely,
Berg
Copy link to clipboard
Copied
The original dropdown field "EPI DESCRIPTION.0" contains a script that populates the "CA.0" field. When you copied the dropdown you also copied this script. Obviosly the script hard codes the destination field name. So you'll need to either modify the script for each different dropdown/text field pair, or write a generic script that will work for all of them, based on the field names.
This article explains how to find the scripts on a form field:
https://www.pdfscripting.com/public/Editing-Fields-Properties.cfm
Please the code you find, and where you found it. And if posssible,post your form so we can take a look at it.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
The problem is this document level function
function SetFieldValues(cDeptName) {
this.getField("CA.0").value = DeptData[cDeptName].contact;
}
It needs to be modified to change the target field name to match the "CA" field on the same line.
BTW: the code on this form looks suspciously like code I've written for other examples. Where did you get it?
Copy link to clipboard
Copied
Thom Parker,
All good?
Thanks for the feedback. I had found this code in an example form in mid-2010 and 2011, doing a search on the internet at the time and saved the file, thinking precisely about studying this JS code in the future.
I ended up facing a situation that referred me to it, I just couldn't imagine having the pleasure of receiving help from its creator. I am honored to be able to be present at this moment. But if I can't use your JS code that's okay, I can delete it right away and I won't use it.
But to understand the logic of the code, for each sublist, I will have to change this command (cDeptName). For example, instead of (cDeptName) I would change to (DESCRIPTION EPI.1), DESCRIPTION EPI.2), DESCRIPTION EPI.3), this in each command line, if I have even DESCRIPTION EPI.20), I will have 20 lines with this command?
Would it be this?
Copy link to clipboard
Copied
Change function to this:
function SetFieldValues(cDeptName) {
var n = event.target.name.split(".");
this.getField("CA."+n[1]).value = DeptData[cDeptName].contact;}
Also in keystroke script to reset form enter actual name like "CA.0", or "CA.1"...etc if you use just "CA" it will reset all "CA" fields, also you don't have space character as default value in dropdowns so change " " to "".
Something like this:
if( event.willCommit )
{
if(event.value == "")
this.resetForm(["CA.1"]);
else
SetFieldValues(event.value);
}
OPTIONAL:
You can also check 'Commit selected value immediately' in dropdown 'Options' tab to show value in "CA" when you select it instead of need to click outside dropdown field.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more