This is driving me nuts!
I have a combo box that I populate from a web service that returns a JSON encoded string as follows…
function doGetCountries() {
//Clear Country drop down
$(‘#m1-pCheckIn-hidden-select-cCountry’).empty();
//Set up AJAX and fill Country drop down
var webURL = “http://www.xxxxxxxx.com/xxxxxxxx/xxxxxxxxx.asmx/GetCountryList”;
$.ajax({
type: “POST”,
url: webURL,
contentType: “application/json”,
dataType: “json”,
success: function(jSON) {
var webJSON = jSON.d;
var webData = webJSON.split(‘;’);
//Parse array into combo
for (var iCount = 2; iCount < webData.length; iCount++) {
$(‘select[name=”cCountry”]’).append( new Option(webData[iCount],webData[iCount]));
}
},
error: function(e){
$(‘#m1-pCheckIn-cTest’).val(‘GetCountryList method failed’);
}
});
//End
$(‘select[name=”cCountry”] option[value=”Argentina”]’).attr(‘selected’,’selected’) ;
phoneui.preprocessDOM(‘#m1-pCheckIn’);
return;
}
The combo box populates correctly.
The problem is that no matter what method I use whether it be..
$(‘select[name=”cCountry”] option[value=”Argentina”]’).attr(‘selected’,’selected’) ;
phoneui.preprocessDOM(‘#m1-pCheckIn’);
or
$(‘select[name=”cCountry”]’).val(“Argentina”);
The combo box ALWAYS has the first list value selected (which is Afghanistan) and ‘Argentina’ is in the list.
HELP!!!