This function allows for the dynamic display of select tags for location selection based on employee designation. The current code functions correctly, but I believe it can be optimized further.
// Function to activate different location options based on employee designation
function location_served_option_by_designation(filter) {
var area_display_setting;
var city_display_setting;
var region_display_setting;
var zone_display_setting;
var country_display_setting;
var location_title;
switch(filter.value.toLowerCase()) {
case 'bm':
// Code for BM designation
break;
case 'abm':
// Code for ABM designation
break;
case 'rsm':
// Code for RSM designation
break;
case 'zsm':
// Code for ZSM designation
break;
case 'nsm':
// Code for NSM designation
break;
}
// Display settings for locations
location_served_area.style.display = area_display_setting;
location_served_country.style.display = country_display_setting;
location_served_title.innerText = location_title[0].toUpperCase() + location_title.slice(1);
}
HTML Markup Image: When 'BM' is selected as the designation, options for country: India, zone: Central Zone, region: Chhattisgarh, and city: Durg1 are displayed. Based on the city, areas for selecting employees service area will be activated. If the designation is 'ZSM', only the country select tag will be activated with checkboxes for choosing zones within that country. https://i.sstatic.net/1xOjH.png