Link to home
Start Free TrialLog in
Avatar of er_maverick
er_maverick

asked on

Drop down not getting populated for IE 7.0

I am having 2 drop down boxes .One for selecting country and another for selecting states of that country.
When i select a country in one drop down box ,corresponding states are getting populated in second drop down box.I am making use of XMLHTTPRequest.This is working fine for IE 6.0.
But this is not working for Mozilla and IE 7.0
Avatar of HugoHiasl
HugoHiasl

It will be hard to assist without seeing some sourcecode how you try to do it.

Like a phonecall in the garage "My car is out of order, what can it be?" :-)


Best regards
Oliver
Avatar of er_maverick

ASKER


<script language="javascript" type="text/javascript">
        
        /* This is AJAX implementation to display states based on the country selected.-->
           This method CountryChanged() is called on Onchange() of the country select field
           This inturn uses AjaxServer.aspx and Ajaxserver.cs
        */
        function CountryChanged(objControl)
        {
            var idStr = objControl.id;
            controlID = idStr.substring(0, idStr.indexOf("_cboLocation"));    
            xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Msxml2.XMLHTTP"); 
            if(typeof xmlhttp == "undefined")
            {
                alert("xmlhttp not created");
            }
            var selectedValue = objControl.value;        
            var url = "../AjaxServer.aspx?MethodName=GetState&selectedValue=" +selectedValue;
            xmlhttp.onreadystatechange = HandleResponse;
            xmlhttp.open("GET",url,true);
            xmlhttp.send(null);
        }
</script>
 
 
 
In AjaxServer.aspx.cs
 
 
private void GetState(string countryCode)
    {
        string langCode = Session["LanguageCode"].ToString();
        StringBuilder sb = new StringBuilder("<States>");
        sb.Append("<State><value>Select a State/Province</value><code>Select a State/Province</code></State>");
        //string countryCode = cboCountry.SelectedValue;
        DataView stateView = GetStatesForCountry(countryCode, langCode);
        if (stateView.Count > 0)
        {
            for (int i = 0; i < stateView.Count; i++)
            {
                sb.Append("<State><value>");
                sb.Append(stateView[i]["value"].ToString());
                sb.Append("</value>");
                sb.Append("<code>");
                sb.Append(stateView[i]["code"].ToString());
                sb.Append("</code></State>");
            }
        }
        else
        {
            sb.Append("<State><value>");
            sb.Append("NA");
            sb.Append("</value>");
            sb.Append("<code>");
            sb.Append("NA");
            sb.Append("</code></State>");
        }
        sb.Append("</States>");
        Response.Write(sb.ToString());
        Response.End();
    }
}

Open in new window

I am having 2 drop down boxes .One for selecting country and another for selecting states of that country.
When i select a country in one drop down box ,corresponding states are getting populated in second drop down box.I am making use of XMLHTTPRequest.This is working fine for IE 6.0.
But this is not working for Mozilla and IE 7.0
no answer
ASKER CERTIFIED SOLUTION
Avatar of HugoHiasl
HugoHiasl

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial