Hi everybody!

I want to load one listbox on the basis of the another in Java. The following function should work while I change country list.

<script>
function loadCountryRegion() {
var selectedCountryName = document.getElementById("listCountry").value;
$('#listCountryRegion').html('');
$.ajax({
type : 'GET',
dataType : 'json',
url : 'cs?action=getCountryRegionList&listCountry='+ selectedCountryName,
success : function(data) {
$.each(data.CountryRegionList, function(i, region) {
$("#listCountryRegion").append(
'<option value="' + region.name +'">'
+ region.name + '</option>');
});
},

});
}
</script>

But selectedCountryName is null. It doesn't contain the country name.

Could you please advise why it is null and what should I do?

Thanks