$(document).ready(function() { //获取省份信息 if($("#cn").val() != undefined){ if($("#cn").val() == "省"){ $("#cn").val(""); } initSelectUlData("cn_son_ul","省","/ssp_operator/operator/main/ap/apmac/cn","province","cnul_span","cnul_box","cn",null); $("ul#cn_son_ul li").live("click",function(){ $("#cnul_span").html($(this).html()); if($(this).html() == "省"){ $("#cn").val(""); }else{ $("#cn").val($(this).html()); } $("#cnCityul_span").html("市"); $("#cnCity").val(""); $("#cn_son_ul").hide(); //ul隐藏 }); } //获取省份对应的城市信息 if($("#cnCity").val() != undefined){ $("#cnCityul_son_ul").hide(); if($("#cnCity").val() == "市"){ $("#cnCity").val(""); } $("#cnCityul_span").on("click",function(){ $("#cnCityul_son_ul").empty(); $('#cnCityul_son_ul').css({height:"auto",overflow:"hidden"}); $("#cnCityul_son_ul").append("
  • "); if($("#cn").val() != null && $("#cn").val() != ""){ var url = "/ssp_operator/main/ap/apmac/city?province=" + $("#cn").val(); $.getJSON( url, function(data) { var data_1 = data.city; $.each( data_1, function( key, val ) { $("#cnCityul_son_ul").append('
  • ' + val + '
  • '); }); $('#cnCityul_son_ul').show(); //ul显示 if($('#cnCityul_son_ul').height()>210){ $('#cnCityul_son_ul').css({"height":"210"+"px","overflow-y":"scroll","overflow-x":"hidden","z-index":"9999" }); }; }); }else{ $('#cnCityul_son_ul').show(); //ul显示 } }); $('ul#cnCityul_son_ul li').live("click",function(){ $("#cnCityul_span").html($(this).html()); if($(this).html() == "省"){ $("#cnCity").val(""); }else{ $("#cnCity").val($(this).html()); } $("#cnCityul_son_ul").hide(); //ul隐藏 }); $("#cnCityul_box").mouseleave(function(){ $('#cnCityul_son_ul').hide(); //ul隐藏 }); } //获取场景信息 if($("#place").val() != undefined){ if($("#place").val() == "场景"){ $("#place").val(""); } initSelectUlData("placeul_son_ul","场景","/ssp_operator/operator/main/ap/apmac/place","place","placeul_span","placeul_box","place",null); $("ul#placeul_son_ul li").live("click",function(){ $("#placeul_span").html($(this).html()); if($(this).html() == "场景"){ $("#place").val(""); }else{ $("#place").val($(this).html()); } $("#placeul_son_ul").hide(); //ul隐藏 }); } //获取场景信息 if($("#placeId").val() != undefined){ if($("#placeId").val() == "数聚场景"){ $("#placeId").val(""); } initSelectUlData("placeIdul_son_ul","数聚场景","/ssp_operator/operator/main/ap/apmac/placeName",null,"placeIdul_span","placeIdul_box","placeName","placeId"); $("ul#placeIdul_son_ul li").live("click",function(){ $("#placeIdul_span").html($(this).html()); if($(this).attr("value") == -1){ $("#placeId").val(""); $("#placeName").val("数聚场景"); }else{ $("#placeId").val($(this).attr("value")); $("#placeName").val($(this).html()); } $("#placeIdul_son_ul").hide(); //ul隐藏 }); } function initSelectUlData(sonulId,defaultValue,url,param,spanName,boxName,useNameValueId,useIdValueId,cityTab){ $("#"+sonulId).hide(); $("#"+sonulId).append('
  • '+defaultValue+'
  • '); if(cityTab == "city" && $("cn").val != "" && $("cn").val != null){} $.getJSON( url, function(data) { if(useIdValueId != null){ $.each( data, function( key, val ) { $("#"+sonulId).append('
  • ' + val.name + '
  • '); }); }else{ var data_1 = data[param]; $.each( data_1, function( key, val ) { $("#"+sonulId).append('
  • ' + val + '
  • '); }); } }); $("#"+spanName).on("click",function(){ if($("#"+sonulId).height()>210){ $("#"+sonulId).css({"height":"210"+"px","overflow-y":"scroll","overflow-x":"hidden","z-index":"9999" }); }; $("#"+sonulId).show(); //ul显示 }); $("#"+boxName).mouseleave(function(){ $("#"+sonulId).hide(); //ul隐藏 }); } });