Expand my Community achievements bar.

SOLVED

How do I assign different text to a floating field based on a drop down list selection?

Avatar

Level 1
Level 1

I am attempting to insert different text options into a floating field based on a number selected in another drop down list - how do I accomplish this?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

You might want to put the code on the Change event of your dropdown list. And also you need to set the Binding of the dropdown list to "Specify Item Values" on the Binding tab of the Object palette - then each of your list items will be assigned a number for use in the script.

In the script you can add a separate "case" statement for each choice in the dropdown list - the case number corresponding to the value of the selection.

var selection = this.boundItem(xfa.event.newText);

switch (selection) {   case "1": // Selection 1    TextField1.rawValue = "item1";
    break;   case "2": // Selection 2     TextField1.rawValue = "item2"     break; } 

In the script above you'll have to change "TextField1" to the name of the text box, you want the text to show up in.

View solution in original post

3 Replies

Avatar

Employee Advisor

Is it an Adaptive form or a PDF form?

Avatar

Correct answer by
Employee Advisor

You might want to put the code on the Change event of your dropdown list. And also you need to set the Binding of the dropdown list to "Specify Item Values" on the Binding tab of the Object palette - then each of your list items will be assigned a number for use in the script.

In the script you can add a separate "case" statement for each choice in the dropdown list - the case number corresponding to the value of the selection.

var selection = this.boundItem(xfa.event.newText);

switch (selection) {   case "1": // Selection 1    TextField1.rawValue = "item1";
    break;   case "2": // Selection 2     TextField1.rawValue = "item2"     break; } 

In the script above you'll have to change "TextField1" to the name of the text box, you want the text to show up in.