function changeSystemDDLIndex() { // Select the Site in SitesDDL = CustomerSiteIdOfSystem // Save the System ID into a hidden variable var systemsDDL = document.getElementById('ddlSystems'); var system = systemsDDL.options[systemsDDL.selectedIndex].value; var sitesDDL = document.getElementById('ddlSites'); var hidCustomerSiteId = document.getElementById("hdnCustomerSiteId"); var hidCustomerSystemId = document.getElementById("hdnCustomerSystemId"); if (systemsDDL.options[systemsDDL.selectedIndex].value == '') { // if System = N/A, Customer_Site_Id = '' then SitesDDL.SelectedIndex = 0 (N/A) sitesDDL.options[0].selected = true; // Set new values of hidden variables hidCustomerSiteId.value = ''; hidCustomerSystemId.value = ''; } else { var isFound = false; var CustomerSiteIdOfSystem = systemsDDL.options[systemsDDL.selectedIndex].attributes['Customer_Site_Id'].value; // Find the Customer_Site_Id in SitesDDL options and set it for (var i = 1; i < sitesDDL.options.length; i++) { if (sitesDDL.options[i].value == CustomerSiteIdOfSystem) { sitesDDL.options[i].selected = true; isFound = true; } else { sitesDDL.options[i].selected = false; } } if (isFound == false) { sitesDDL.options[0].selected = true; sitesDDL.options[0].disabled = false; } // Set new values of hidden variables hidCustomerSiteId.value = CustomerSiteIdOfSystem; hidCustomerSystemId.value = system; } return; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)