锘縡unction SelCity(obj,e) { var ths = obj; var dal = '
'; Iput.show({ id: ths, event: e, content: dal,width:"470"}); $("#cColse").click(function () { Iput.colse(); }); var tb_province = []; var b = province; for (var i = 0, len = b.length; i < len; i++) { tb_province.push('' + b[i]['name'] + ''); } $("#_citys0").append(tb_province.join("")); $("#_citys0 a").click(function () { var g = getCity($(this)); $("#_citys1 a").remove(); $("#_citys1").append(g); $("._citys1").hide(); $("._citys1:eq(1)").show(); var lev = $(this).data("name"); $(ths).val($(this).data("name")).css("color","#333"); $("#sheng").html(lev); $("#hproper").remove(); $("#harea").remove(); if (document.getElementById("hcity") == null) { var hcitys = $('', { type: 'hidden', name: "hcity", "data-id": $(this).data("id"), id: "hcity", val: lev }); $(ths).after(hcitys); } else { $("#hcity").val(lev); $("#hcity").attr("data-id", $(this).data("id")); } $("#_citys1 a").click(function () { var lev = $(this).data("name"); $("#shi").html(lev); $("#harea").remove(); if (document.getElementById("hproper") == null) { var hcitys = $('', { type: 'hidden', name: "hproper", "data-id": $(this).data("id"), id: "hproper", val: lev }); $(ths).after(hcitys); } else { $("#hproper").attr("data-id", $(this).data("id")); $("#hproper").val(lev); } var bc = $("#hcity").val(); $(ths).val(bc+ "-" + $(this).data("name")).css("color","#333"); var ar = getArea($(this)); $("#_citys2 a").remove(); $("#_citys2").append(ar); $("._citys1").hide(); $("._citys1:eq(2)").show(); $("#_citys2 a").click(function () { var lev = $(this).data("name"); $("#xian").html(lev); if (document.getElementById("harea") == null) { var hcitys = $('', { type: 'hidden', name: "harea", "data-id": $(this).data("id"), id: "harea", val: lev }); $(ths).after(hcitys); } else { $("#harea").val(lev); $("#harea").attr("data-id", $(this).data("id")); } var bc = $("#hcity").val(); var bp = $("#hproper").val(); /*ths.value = bc + "-" + bp + "-" + $(this).data("name");*/ $(ths).val(bc + "-" + bp + "-" + $(this).data("name")).css("color","#333"); Iput.colse(); }); }); }); $("#_citysheng li").click(function () { $("#_citysheng li").removeClass("citySel"); $(this).addClass("citySel"); var s = $("#_citysheng li").index(this); $("._citys1").hide(); $("._citys1:eq(" + s + ")").show(); }); } function getCity(obj) { var c = obj.data('id'); var e = province; var f; var g = ''; for (var i = 0, plen = e.length; i < plen; i++) { if (e[i]['id'] == parseInt(c)) { f = e[i]['city']; break } } for (var j = 0, clen = f.length; j < clen; j++) { g += '' + f[j]['name'] + '' } $("#_citysheng li").removeClass("citySel"); $("#_citysheng li:eq(1)").addClass("citySel"); return g; } function getArea(obj) { var c = obj.data('id'); var e = area; var f = []; var g = ''; for (var i = 0, plen = e.length; i < plen; i++) { if (e[i]['pid'] == parseInt(c)) { f.push(e[i]); } } for (var j = 0, clen = f.length; j < clen; j++) { g += '' + f[j]['name'] + '' } $("#_citysheng li").removeClass("citySel"); $("#_citysheng li:eq(2)").addClass("citySel"); return g; }