• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How To Populate Text Field When A Drop Down List Item From Another Field Is Selected

Participant ,
Sep 05, 2021 Sep 05, 2021

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?

TOPICS
JavaScript

Views

4.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 05, 2021 Sep 05, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 05, 2021 Sep 05, 2021

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;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 05, 2021 Sep 05, 2021

Copy link to clipboard

Copied

This code should work.

What exactly happen when you use it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 05, 2021 Sep 05, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 05, 2021 Sep 05, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 05, 2021 Sep 05, 2021

Copy link to clipboard

Copied

Where exactly did you place the code? Under which event?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 05, 2021 Sep 05, 2021

Copy link to clipboard

Copied

I placed the code in the "E" drop-down menu custom validation script

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 05, 2021 Sep 05, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 05, 2021 Sep 05, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 06, 2021 Sep 06, 2021

Copy link to clipboard

Copied

 

EDIT:

Can you try this code:

if(event.value == "A")this.getField("A").value = this.getField("C").value;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 06, 2021 Sep 06, 2021

Copy link to clipboard

Copied

Thank you very much. The formula works

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 06, 2021 Sep 06, 2021

Copy link to clipboard

Copied

That's not what I suggested. Read my reply again.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 13, 2021 Sep 13, 2021

Copy link to clipboard

Copied

Many thanks for the help. Problem solved

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines