三级联动的代码*(心情很差呀,白忙了一上午,说要搞离线的,记录下来呗,已被不时之需)
function hdfsUpload(){
cmApi.request.httpGetAsync('/xzqh/getXzqh',JSON.stringify({"province":"province"}),'mainModule.xzqh');
}
function xzqh(ret){
var province = [];
var len = ret.length;
for (var i = 0;i < len;i++){
var objPro = {};
objPro["p_id"] = ret[i].ggfwXzqhCjdm;
objPro["name"] = ret[i].ggfwXzqhCjmc;
province.push(objPro);
}
var select = $("#pro");
select.empty();
var lenPro = province.length;
for (var j = 0;j < lenPro;j++){
var options = '<option value="'+province[j].p_id+'" >'
+ province[j].name
+'</option>';
select.append(options);
}
cmApi.request.httpGetAsync('/xzqh/getXzqhsj',JSON.stringify({"proId":province[0].p_id}),'mainModule.xzqhsj');
$("#pro").change(function(){
cmApi.request.httpGetAsync('/xzqh/getXzqhsj',JSON.stringify({"proId":$(this).val()}),'mainModule.xzqhsj');
})
}
function xzqhsj(ret){
var sjArr = [];
var len = ret.length;
for (var i = 0;i < len;i++){
var objPro = {};
objPro["sj_id"] = ret[i].ggfwXzqhCjdm;
objPro["name"] = ret[i].ggfwXzqhCjmc;
sjArr.push(objPro);
}
var select = $("#sj");
select.empty();
var lenPro = sjArr.length;
for (var j = 0;j < lenPro;j++){
var options = '<option value="'+sjArr[j].sj_id+'" >'
+ sjArr[j].name
+'</option>';
select.append(options);
}
cmApi.request.httpGetAsync('/xzqh/getXzqhxj',JSON.stringify({"sjId":sjArr[0].sj_id}),'mainModule.xzqhxj');
$("#sj").change(function(){
// alert($(this).val());
cmApi.request.httpGetAsync('/xzqh/getXzqhxj',JSON.stringify({"sjId":$(this).val()}),'mainModule.xzqhxj');
})
}
function xzqhxj(ret){
var xjArr = [];
var len = ret.length;
for (var i = 0;i < len;i++){
var objPro = {};
objPro["xj_id"] = ret[i].ggfwXzqhCjdm;
objPro["name"] = ret[i].ggfwXzqhCjmc;
xjArr.push(objPro);
}
var select = $("#xj");
select.empty();
var lenPro = xjArr.length;
for (var j = 0;j < lenPro;j++){
var options = '<option value="'+xjArr[j].xj_id+'" >'
+ xjArr[j].name
+'</option>';
select.append(options);
}
}