123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- $(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("<li value='-1'>市</li>");
- 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('<li>' + val + '</li>');
- });
- $('#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('<li value="-1">'+defaultValue+'</li>');
- if(cityTab == "city" && $("cn").val != "" && $("cn").val != null){}
- $.getJSON( url, function(data) {
- if(useIdValueId != null){
- $.each( data, function( key, val ) {
- $("#"+sonulId).append('<li value='+ val.place_id +'>' + val.name + '</li>');
- });
- }else{
- var data_1 = data[param];
- $.each( data_1, function( key, val ) {
- $("#"+sonulId).append('<li>' + val + '</li>');
- });
- }
- });
- $("#"+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隐藏
- });
- }
-
- });
|