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
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

ENE5CD9Author
Inspiring
September 5, 2021

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