var provid; //
var cityid;
var areaid;
function initcomplexarea(provcontrol, citycontrol, areacontrol, prov, city, area, provvalue, cityvalue, areavalue) {
provid = provcontrol;
cityid = citycontrol;
areaid = areacontrol;
var f = initcomplexarea.arguments;
var m = document.getelementbyid(provcontrol);
var o = document.getelementbyid(citycontrol);
var n = document.getelementbyid(areacontrol);
var e = 0;
var c = 0;
if (prov != undefined) {
if (provvalue != undefined) {
provvalue = parseint(provvalue);
}
else {
provvalue = 0;
}
if (cityvalue != undefined) {
cityvalue = parseint(cityvalue);
}
else {
cityvalue = 0;
}
if (areavalue != undefined) {
areavalue = parseint(areavalue);
}
else {
areavalue = 0
}
n[0] = new option(optiontext, 0);
o[0] = new option(optiontext, 0);
for (e = 0; e < prov.length; e++) {
if (prov[e] == undefined) {
continue;
}
if (f[6]) {
if (f[6] == true) {
if (e == 0) {
continue;
}
}
}
m[c] = new option(prov[e], e);
if (provvalue == e) {
m[c].selected = true;
}
c++;
}
if (city[provvalue] != undefined && city[provvalue] != optiontext) {//optiontext变量在areadata_min_cn.js中
c = 0; for (e = 0; e < city[provvalue].length; e++) {
if (city[provvalue][e] == undefined) { continue }
if (f[7]) {
if ((f[7] == true) && (provvalue != 71) && (provvalue != 81) && (provvalue != 82)) {
if ((e % 100) == 0) { continue; }
}
}
o[c] = new option(city[provvalue][e], e);
if (cityvalue == e) { o[c].selected = true }
c++;
}
} else {
jquery("#" + citycontrol).hide();
}
if (area[cityvalue] != undefined && area[cityvalue] != optiontext) {
c = 0; for (e = 0; e < area[cityvalue].length; e++) {
if (area[cityvalue][e] == undefined) { continue }
if (f[8]) {
if ((f[8] == true) && (provvalue != 71) && (provvalue != 81) && (provvalue != 82)) {
if ((e % 100) == 0) { continue; }
}
}
n[c] = new option(area[cityvalue][e], e);
if (areavalue == e) { n[c].selected = true }
c++;
}
} else {
jquery("#" + areacontrol).hide();
}
}
}
//三级----选择省份
//changecomplexprovince(this.value, sub_array, '9220_seachcity', '9220_seachdistrict','9220');"
function changecomplexprovince(pvalue, sub_array, provinceid, cityid, districtid, hiddenid) {
var c = changecomplexprovince.arguments;
var h = document.getelementbyid(cityid);
var g = document.getelementbyid(districtid);
var b = 0;
var a = 0;
removeoptions(h);
pvalue = parseint(pvalue);
if (sub_array[pvalue] != undefined) {
for (b = 0; b < sub_array[pvalue].length; b++) {
if (sub_array[pvalue][b] == undefined) { continue }
h[a] = new option(sub_array[pvalue][b], b);
a++
}
}
removeoptions(g);
g[0] = new option(optiontext, 0);
//清空
$("#" + hiddenid).val("");
var pv = $("#" + provinceid).find("option:selected").val();
if (pv != '0') {//没下一级就设省
$("#" + hiddenid).val($("#" + provinceid).find("option:selected").val());
}
}
//一级----省份
function changelevel1province(id, k, e, d, hiddenid) {
if ($("#" + id).find("option:selected").val() != '0') {
var name = $("#" + id).find("option:selected").val();
$("#" + hiddenid).val(name);
}
else {
$("#" + hiddenid).val("");
}
}
//二级---省份
//changecomplexprovince(this.value, sub_array, '9220_seachcity', '9220_seachdistrict','9220');
function changecomplexprovince(pvalue, sub_array, provinceid, cityid, districtid, hiddenid) {
var c = changecomplexprovince.arguments;
var h = document.getelementbyid(cityid);
var g = document.getelementbyid(districtid);
var b = 0;
var a = 0;
removeoptions(h);
pvalue = parseint(pvalue);
if (sub_array[pvalue] != undefined) {
for (b = 0; b < sub_array[pvalue].length; b++) {
if (sub_array[pvalue][b] == undefined) {
continue
}
h[a] = new option(sub_array[pvalue][b], b);
a++
}
}
removeoptions(g);
g[0] = new option(optiontext, 0);
//清空
$("#" + hiddenid).val("");
if (a == 1 && pvalue != 0) {//没下一级就设省
$("#" + cityid).hide();
$("#" + districtid).hide();
} else {
$("#" + cityid).show();
$("#" + districtid).hide();
}
if (a == 0 && pvalue == 0) {
$("#" + cityid).hide();
}
var pv = $("#" + provinceid).find("option:selected").val();
if (pv == '0') {
$("#" + hiddenid).val('');
} else {
$("#" + hiddenid).val(pv);
}
}
//二级---市
function changelevel2city(id, a, t, hiddenid) {
if ($("#" + id).find("option:selected").val() != '0') {
var name = $("#" + id).find("option:selected").val();
$("#" + hiddenid).val(name);
} else if ($("#" + id).find("option:selected").val() == '0') {
$("#" + hiddenid).val($("#" + provid).find("option:selected").val());
}
}
//三级----更换城市
function changecity(cityvalue, cityid, districtid, hiddenid) {
$("#" + districtid).html('');
$("#" + districtid).unbind("change");
cityvalue = parseint(cityvalue);
var _d = sub_arr[cityvalue];
var str = "";
str += "";
if (_d!= undefined && _d.length <= 1) {
if ($("#" + cityid).find("option:selected").val() != "0") {
var backtext = $("#" + cityid).find("option:selected").val();
$("#" + hiddenid).val(backtext);
} else {
$("#" + hiddenid).val('');
}
}
if (_d != undefined) {
for (var i = cityvalue; i < _d.length; i++) {
if (_d[i] == undefined) continue;
str += "";
}
if (_d.length > 1) {
$("#" + districtid).show();
} else {
$("#" + districtid).hide();
}
}
$("#" + districtid).html(str);
//更换市处理
var cityv = $("#" + cityid).find("option:selected").val();
if (cityv != '0') { //市选项不为请选择
$("#" + hiddenid).val(cityv);
} else { //市选项为请选择,设省
var pv = $("#" + provid).find("option:selected").val();
if (pv != '0') {
$("#" + hiddenid).val(pv);
} else {
$("#" + hiddenid).val('');
}
}
}
function removeoptions(c) {
if ((c != undefined) && (c.options != undefined)) {
var a = c.options.length;
for (var b = 0; b < a; b++) {
c.options[0] = null;
}
}
}
//设置地区进隐藏控件
function setvalue(id, hiddenid) {
//更区处理
var areav = $("#" + areaid).find("option:selected").val();
if (areav == '0') {
var cityv = $("#" + cityid).find("option:selected").val();
if (cityv != '0') { //市选项不为请选择
$("#" + hiddenid).val(cityv);
} else { //市选项为请选择,设省
var pv = $("#" + provid).find("option:selected").val();
if (pv != '0') {
$("#" + hiddenid).val(pv);
} else {
$("#" + hiddenid).val('');
}
}
} else {
$("#" + hiddenid).val(areav);
}
}