How do I assign different text to a floating field based on a drop down list selection? | Community
Skip to main content
June 6, 2019
Solved

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

  • June 6, 2019
  • 3 replies
  • 1319 views

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.
Best answer by Mayank_Gandhi

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
June 6, 2019

Is it an Adaptive form or a PDF form?

DZWAuthor
June 6, 2019

PDF

Mayank_Gandhi
Adobe Employee
Mayank_GandhiAdobe EmployeeAccepted solution
Adobe Employee
June 18, 2019

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.