Skip to main content
Inspiring
September 5, 2021
Question

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

  • September 5, 2021
  • 1 reply
  • 6438 views

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?

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
September 5, 2021

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.

ENE5CD9Author
Inspiring
September 5, 2021

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;

Nesa Nurani
Community Expert
Community Expert
September 6, 2021

This code should work.

What exactly happen when you use it?