js ajax
$(document).ready(function() {
$('#provinceId_edit').change(function() {
var p1 = $(this).children('option:selected').val();
$.ajax({
url : base + "/user01/chgProv",
data : {
provinceId : p1,
},
type : 'post',
cache : false,
dataType : 'json',
success : function(data) {
$("#cityId_edit").html("");
$("#cityId_edit").append("<option></option>");
$.each(data.cityList, function(entryIndex, entry) {
$("#cityId_edit").append("<option value=" + entry['id'] + ">" + entry['name'] + "</option>");
});
$("#countyId_edit").html("");
},
error : function() {
}
});
});
$('#cityId_edit').change(function() {
var p1 = $('#provinceId_edit').children('option:selected').val();
var p2 = $(this).children('option:selected').val();
$.ajax({
url : base + "/user01/chgCity",
data : {
provinceId : p1,
cityId : p2,
},
type : 'post',
cache : false,
dataType : 'json',
success : function(data) {
$("#countyId_edit").html("");
$("#countyId_edit").append("<option></option>");
$.each(data.countyList, function(entryIndex, entry) {
$("#countyId_edit").append("<option value=" + entry['id'] + ">" + entry['name'] + "</option>");
});
},
error : function() {
}
});
});
$('.field').change(function() {
var p1 = $('#provinceId_edit').children('option:selected').val();
var p2 = $('#cityId_edit').children('option:selected').val();
var p3 = $('#countyId_edit').children('option:selected').val();
$.ajax({
url : base + "/yellowPage01/leadin/item/getcourt",
data : {
provinceId : p1,
cityId : p2,
countyId:p3,
},
type : 'post',
cache : false,
dataType : 'json',
success : function(data) {
$("#court_edit").html("");
$("#court_edit").append("<option></option>");
$.each(data.courtList, function(entryIndex, entry) {
$("#court_edit").append("<option value=" + entry['courtId'] + ">" + entry['court'] + "</option>");
});
},
error : function() {
}
});
});
$('#submit_edit').click(function() {
var price = $('#price').val();
var province = $('#provinceId_edit').val();
if(province =="" ){
alert("请选择地市!");
return false ;
}else if(price == ""){
alert("请输入法院/检察院");
return false ;
}else{
$('form').submit();
}
});
});
base = document.getElementById("base").href;
$(document).ready(function() {
$('#provinceId_edit').change(function() {
var p1 = $(this).children('option:selected').val();
$.ajax({
url : base + "/user01/chgProv",
data : {
provinceId : p1,
},
type : 'post',
cache : false,
dataType : 'json',
success : function(data) {
$("#cityId_edit").html("");
$("#cityId_edit").append("<option></option>");
$.each(data.cityList, function(entryIndex, entry) {
$("#cityId_edit").append("<option value=" + entry['id'] + ">" + entry['name'] + "</option>");
});
$("#countyId_edit").html("");
},
error : function() {
}
});
});
$('#cityId_edit').change(function() {
var p1 = $('#provinceId_edit').children('option:selected').val();
var p2 = $(this).children('option:selected').val();
$.ajax({
url : base + "/user01/chgCity",
data : {
provinceId : p1,
cityId : p2,
},
type : 'post',
cache : false,
dataType : 'json',
success : function(data) {
$("#countyId_edit").html("");
$("#countyId_edit").append("<option></option>");
$.each(data.countyList, function(entryIndex, entry) {
$("#countyId_edit").append("<option value=" + entry['id'] + ">" + entry['name'] + "</option>");
});
},
error : function() {
}
});
});
$('.field').change(function() {
var p1 = $('#provinceId_edit').children('option:selected').val();
var p2 = $('#cityId_edit').children('option:selected').val();
var p3 = $('#countyId_edit').children('option:selected').val();
$.ajax({
url : base + "/yellowPage01/leadin/item/getcourt",
data : {
provinceId : p1,
cityId : p2,
countyId:p3,
},
type : 'post',
cache : false,
dataType : 'json',
success : function(data) {
$("#court_edit").html("");
$("#court_edit").append("<option></option>");
$.each(data.courtList, function(entryIndex, entry) {
$("#court_edit").append("<option value=" + entry['courtId'] + ">" + entry['court'] + "</option>");
});
},
error : function() {
}
});
});
$('#submit_edit').click(function() {
var price = $('#price').val();
var province = $('#provinceId_edit').val();
if(province =="" ){
alert("请选择地市!");
return false ;
}else if(price == ""){
alert("请输入法院/检察院");
return false ;
}else{
$('form').submit();
}
});
});
controller:
// 修改地区后 找出对应的 court
@RequestMapping(value = { "/leadin/item/getcourt" })
@ResponseBody
public Map<String, Object> getCourt(ModelMap model, String provinceId, String cityId, String countyId, HttpSession httpsession, Integer courtId) {
yellowPage01Service.add(model, provinceId, cityId, countyId, courtId);
Map<String, Object> map = new HashMap<String, Object>();
map.put("courtList", model.get("courtList"));
return map;
}