function doRequest(url, selectId,parentCode,nullText,selectedValue,callbackFunction){
	$.ajax({
		type: "post",
		url: url + parentCode,
		dataType: "text",
		success: function(data){
			appendChildToSelect(data,selectId,nullText,selectedValue);
			//回调函数
			if(callbackFunction != undefined) 
				callbackFunction();
		}
	});
}

//点击某一个省份查询城市
//selectId为目标下拉菜单的id，parentCode为所查的城市编码
var result = "";
function loadCities(selectId,parentCode,nullText,selectedValue,callbackFunction){
	doRequest("commonQuery!loadCityBeans.action?cityCode=", selectId,parentCode,nullText,selectedValue,callbackFunction);
}
function loadAreas(selectId,parentCode,nullText,selectedValue,callbackFunction){
	doRequest("commonQuery!loadAreaBeans.action?cityCode=", selectId,parentCode,nullText,selectedValue,callbackFunction);
}
//将字符串转化成option填到select中
//str字符串格式："100000001335=重庆,100000001327=四川"
function appendChildToSelect(str,selelctId,nullText,selectedValue){
	var citySelect = document.getElementById(selelctId);
	citySelect.options.length = 0;
	if(nullText != undefined && nullText != null && nullText != ""){
		var opt_first=document.createElement("option"); 
	    opt_first.innerText = nullText; 
	    opt_first.value = ""; 
	    citySelect.appendChild(opt_first);
    }
	var oneCity = str.split(",");
	var flag = false;
	for(i=0;i<oneCity.length;i++){
		var temp = oneCity[i].split("=");
		if(temp[0]){
			var opt=document.createElement("option"); 
	        opt.innerHTML = temp[1];
	        opt.value = temp[0];
	        if(temp[0]==selectedValue){
	        	flag = true;
	        }
	        citySelect.appendChild(opt);
        }
	}
	if(flag)
		$(citySelect).attr("value", selectedValue);
	else
		citySelect.selectedIndex = 0;
}
//页面初始化时查询省份
function loadProvince(provinceSelectId,cityCode){
	loadCities(provinceSelectId,cityCode);
}


