Dependent Dropdown not clearing

35 views
Skip to first unread message

Brenda Bourgette

unread,
Jan 22, 2024, 7:27:13 PMJan 22
to Adobe LiveCycle Developers
I have two dropdown lists:  Sector and Branch.  I want the Branch dropdown to have different choices depending on what is chosen from the Sector dropdown.

I put the following code in the Exit event of the Sector dropdown using FormCalc  :

Branch.clearItems(); // clear out Branch in case the user has chosen something else first


I put the following code in the Enter event  of the Branch dropdown using FormCalc :


Branch.clearItems(); // clear out Branch in case the user has chosen something else first

 

if (Sector== "1")then

        Branch.clearItems()

        Branch.addItem("Not Applicable")

               

elseif (Sector== "2")then

        Branch.clearItems()

        Branch.addItem("Not Applicable")

       

elseif (Sector== "3")then

        Branch.clearItems()    

        Branch.addItem("Not Applicable")

       

elseif (Sector== "4")then

        Branch.clearItems()

        Branch.addItem("Service Branch")

 

elseif (Sector== "5")then

        Branch.clearItems()

        Branch.addItem("Communications Services")

        Branch.addItem("Technology Services")

 

elseif (Sector== "6")then

        Branch.clearItems()

        Branch.addItem("Branch 1")

        Branch.addItem("Branch 2")

        Branch.addItem("Branch 3")

        Branch.addItem("Branch 4")

 

endif

 

It works except it does not clear the previous choice from the Branch dropdown if something else is chosen from the Sector dropdown.


Ideally if there is only one choice in Branch (eg. Sector  = 1) I would like the choice "Not Applicable"  automatically entered into the Branch dropdown instead of choosing it from the list.


Any help is greatly appreciated.




Brenda Bourgette

unread,
Jan 23, 2024, 10:49:01 AMJan 23
to Adobe LiveCycle Developers
I got it to work with the following code in the Change event of the first dropdown (Sector).

// Depending on choice made in Sector the Branch dropdown will change

 

var newVal = this.boundItem(xfa.event.newText);  // Stores the dropdown value when the user selects something from the drop down list.

switch (newVal) // the selection in the Sector dropdown populates the Branch field

{

    case "1":

        Branch.clearItems();

        Branch.rawValue = null;

        Branch.rawValue = "Not Applicable";      

        break;

       

    case "2":

        Branch.clearItems();

        Branch.rawValue = null;

        Branch.rawValue = "Not Applicable";             

        break;

       

        case "4":

        Branch.clearItems();

        Branch.rawValue = null;

        Branch.rawValue = "Branch 1";             

        break

        

        case "5":

        Branch.clearItems();

        Branch.rawValue = null;

        Branch.addItem("Branch 2")

        Branch.addItem("Branch 3")

        Branch.addItem("Branch 4")

        break;                    

    default:

    break;


Reply all
Reply to author
Forward
0 new messages