Copy link to clipboard
Copied
Hi
I ask you if, please, someone can solve this question for me.
How to Populate text field (eg "A") when A Drop Down List Item From Another Field Is Selected (eg "B") by copying the contents of another text field (eg "C"). The text fields "A" and "C" are not drop-down menus.
I would like to insert the formula in the drop down "B".
I found this formula
switch (event.value)
{case "x": this.getField ("y"). setItems (["1,2,3,4"]); break;
I was unable to adapt it to the function I need.
Please, anyone who can help me?
Copy link to clipboard
Copied
From my understanding you want to populate text field "A" with value from text field "C" if certain value in dropdown "B" is selected, first of the script you provided is to set items into dropdown fields so that is not what you asking for.
Here is script to populate field "A", use it in dropdown field as 'validation' script:
if(event.value == "value1")
this.getField("A").value = this.getField("C").value;
You can add:
else this.getField("A").value = "";
to the bottom of the script if you wish to empty field "A" if some other item is selected in dropdown.
Change "value1" to the actual value you have in dropdown and tick 'commit selected value immediately' in dropdown field->options tab.
Copy link to clipboard
Copied
Hi
Thank you for your reply.
I followed your instructions, but it doesn't work.
This is the script I placed in the drop-down menu validation script
if (event.value == "A")
this.getField ("A"). value = this.getField ("C"). value;
Copy link to clipboard
Copied
This code should work.
What exactly happen when you use it?
Copy link to clipboard
Copied
Can you help me! I am working with a form created in Adobe DC. I have a dropdown field that needs to autopopulate 5 other text fields with different values based on the selection from the dropdown.
Thank you.
Copy link to clipboard
Copied
Hi
I have tried this feature
var f = this.getField ("A");
if (f.valueAsString == "A") {this.getField ("A"). value = this.getField ("C"). value;}
In the drop-down menu I have entered the letters "A" and "B". I have flagged all the options in the "options" tab.
When I select the letter "A" nothing happens, while when I select the letter "B", the value entered in the "C" text field appears in the "A" text field.
Please, is anyone kind enough to explain to me why this happens?
Thanks
Copy link to clipboard
Copied
Hi
I have tried this feature
var f = this.getField ("E");
if (f.valueAsString == "A") {this.getField ("A"). value = this.getField ("C"). value;}
In the drop-down menu I have entered the letters "A" and "B". I have flagged all the options in the "options" tab.
When I select the letter "A" nothing happens, while when I select the letter "B", the value entered in the "C" text field appears in the "A" text field.
Please, is anyone kind enough to explain to me why this happens?
Thanks
Copy link to clipboard
Copied
Where exactly did you place the code? Under which event?
Copy link to clipboard
Copied
I placed the code in the "E" drop-down menu custom validation script
Copy link to clipboard
Copied
OK, then to access the newly selected value you must use event.value, not this.getField("E").valueAsString.
That will return the field's current (ie. old) value, as the new one hasn't been approved yet by the validation event.
Copy link to clipboard
Copied
hi
I changed the formula like this
var f = this.getField ("E");
if (f.value == "A") {this.getField ("A"). value = this.getField ("C"). value;}
The result does not change. When I select the letter "A" from the drop-down menu, nothing happens. When I select the letter "B", the contents of the "C" text field appear in the "A" text field.
Copy link to clipboard
Copied
EDIT:
Can you try this code:
if(event.value == "A")this.getField("A").value = this.getField("C").value;
Copy link to clipboard
Copied
Thank you very much. The formula works
Copy link to clipboard
Copied
That's not what I suggested. Read my reply again.
Copy link to clipboard
Copied
Many thanks for the help. Problem solved