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.
// 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;
}