Adam,
When I copied the code into the editor and added the appropriately named elements, there is this error which means that you are not properly “closing off” an if statement.
When there are more than two possibilities that you have to handle, Javascript has the switch statement . It’s a cleaner way to handle the various options. This is how how it would be used with the code you have so far:
$w.onReady(function() {
let placeholderStr = "", placeholdText = "";
$w('#subPrefix').options = Mr;
$w('#prefix').onChange(() => {
switch ($w('#prefix').value) {
case 'Mr':
$w('#subPrefix').disable();
$w("#subPrefix").value = null;
$w("#actual").value = null;
placeholderStr = $w("#subPrefix").placeholder = "Option Disabled"; // "Enter name"
placeholdText = $w("#actual").placeholder = "Option Disabled"; // "Enter name"
break;
case 'Mrs':
$w('#subPrefix').disable();
$w("#subPrefix").value = null;
$w("#actual").value = null;
placeholderStr = $w("#subPrefix").placeholder = "Option Disabled"; // "Enter name"
placeholdText = $w("#actual").placeholder = "Option Disabled"; // "Enter name"
break;
case 'Military Officer':
$w('#subPrefix').options = MilitaryOfficer;
$w('#subPrefix').placeholder = 'A Prefix for a Military Officer';
placeholdText = $w("#actual").placeholder = "Option Disabled"; // "Enter name"
$w('#subPrefix').enable();
$w("#actual").value = null;
$w("#prefix").value = null;
break;
default:
$w('#actual').expand();
$w('#actual').options = AddmyOwnPrefix;
$w('#prefix').disable();
$w('#subPrefix').disable();
$w("#prefix").value = null;
$w("#subPrefix").value = null;
break;
}
})
});
Also, your code suggests that you have MilitaryOfficer and AddmyOwnPrefix arrays in memory and that they are going to be used to populate the subPrefix dropdown. I didn’t see in your code where you defined these arrays. To properly assign values to a dropdown in code, you have to construct the array like the documentation suggests: