Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
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;
        }


What I have tried:

I tried differet simple for statements. I tried using different .Net targetFramework. I also tried to add AJAX extension, ScriptManager.
Posted
Comments
Mehdi Gholam 5-Aug-17 8:03am    
Check your html for matching closing of tags.
Karthik_Mahalingam 6-Aug-17 23:51pm    
post your markup

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900