Question : Weird Javascript behvior using alerts

Hello Experts -

I'm getting some bizarre behavior I can't figure with Javascript - in the attached code, for some reason the City dropdown list isn't defaulting to the proper item, but when I put in an alert,  the dropdown accepts the selected value I'm passing to it. Somehow adding an alert is changing the value somehow? I tried setting the value to a string (commons.City_ID.toString();) but that didn't work. Any suggestions?

Thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
function callBackGetCommons(result) {
    var commons = Sys.Serialization.JavaScriptSerializer.deserialize(result);
    ...
    var oDD = document.getElementById("ddCity"); // City dropdown list
    if (commons.City_ID != "") {
         //alert(commons.City_ID);
         oDD.options.value = commons.City_ID;
    }
}

Answer : Weird Javascript behvior using alerts

Ajax calls ?

When you have the alert you get another value from the ajax call have time to finish and come with valid data
Random Solutions  
 
programming4us programming4us