Skip to main content
Jun 6, 2019 11:14 AM UTC
Solved

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

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Mayank_Gandhi
Mayank_GandhiAccepted solution
Adobe Employee
Jun 18, 2019 2:31 PM UTC

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.

3 replies

Mayank_Gandhi
Adobe Employee
Adobe Employee
Jun 6, 2019 2:33 PM UTC

Is it an Adaptive form or a PDF form?

Translate
DZWAuthor
Jun 6, 2019 2:57 PM UTC

PDF

Translate
Mayank_Gandhi
Adobe Employee
Mayank_GandhiAdobe EmployeeAccepted solution
Adobe Employee
Jun 18, 2019 2:31 PM UTC

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.

Translate