%PDF- %PDF-
| Direktori : /home/casasmonvl/coronamillennial/Scripts/address/ |
| Current File : /home/casasmonvl/coronamillennial/Scripts/address/address.js |
$(document).ready(function () {
//Inicialitzacions d'elements
$("#OtherCountry").hide();
//Dropdownlist Selectedchange event
//Per ProvinceSelected
$("#CountrySelected").change(function () {
$("#ProvinceSelected").empty();
$("#LocalitySelected").empty();
var value = $("#CountrySelected").val(); //get the value
//Si es selecciona afegir-ne un de nou: Eliminem dropdownlist i mostrem textbox de País, Provincia i Localitat
if (value == "NEW") {
//alert("visible!");
$
$("#OtherCountry").show(); //"highlight", { color: "#7FAAFF" }, 1000); amb això, la segona vegada es comporta malament
}
//SINO Busquem Provincia correponent al país
else {
//alert("amagat!");
$("#OtherCountry").hide();
$.ajax({
type: 'POST',
url: actionGetProvince, //'(arroba)Url.Action("GetProvince")', // we are calling json method
dataType: 'json',
data: { code: $("#CountrySelected").val() },
// here we are get value of selected country and passing same value
// as input to json method GetStates.
success: function (provinces) {
// provinces contains the JSON formatted list
// of provinces passed from the controller
//Afegim element a la llista, perquè es puguin seleccionar totes les provincies
$("#ProvinceSelected").append('<option>' + strProvinceSelected + '</option>'); //'@Resources.ProvinceSelected'
$.each(provinces, function (i, provincia) {
//$("#ProvinceSelected").append('<option> Selecciona Provincia </option>');
$("#ProvinceSelected").append('<option value="'
+ provincia.id + '">'
+ provincia.name + '</option>');
// here we are adding option for provinces
});
},
error: function (ex) {
alert('Failed to retrieve states.' + ex);
}
});
}
return false;
})
});
$(document).ready(function () {
//Dropdownlist Selectedchange event
//Per LocalitySelected
$("#ProvinceSelected").change(function () {
$("#LocalitySelected").empty();
$.ajax({
type: 'POST',
url: actionGetLocality, //'(arroba)Url.Action("GetLocality")',
dataType: 'json',
data: { id: $("#ProvinceSelected").val(), code: $("#CountrySelected").val() }, //enviem dada de la provincia seleccionada per ID
success: function (citys) {
// citys contains the JSON formatted list
// of citys passed from the controller
//Afegim element a la llista, perquè es puguin seleccionar tots els municipis
$("#LocalitySelected").append('<option>' + strLocalitySelected + '</option>');
$.each(citys, function (i, ciutat) {
$("#LocalitySelected").append('<option value="'
+ ciutat.id + '">'
+ ciutat.name + '</option>');
});
},
error: function (ex) {
alert('Failed to retrieve states.' + ex);
}
});
return false;
})
});