梦幻之旅

DEBUG - 天道酬勤

   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  671 随笔 :: 6 文章 :: 256 评论 :: 0 Trackbacks
/*
*Write by:Hui wanpeng
*Time    :2009-01-13
*vision  :1.0
*/
var PC ={
    
/** 省份数据 */
    p : [{k:
"上海",v:"上海"},
        {k:
"北京",v:"北京"},
        {k:
"广东",v:"广东"},
        {k:
"江苏",v:"江苏"},
        {k:
"浙江",v:"浙江"},
        {k:
"山东",v:"山东"},
        {k:
"天津",v:"天津"},
        {k:
"重庆",v:"重庆"},
        {k:
"四川",v:"四川"},
        {k:
"河北",v:"河北"},
        {k:
"山西",v:"山西"},
        {k:
"内蒙古",v:"内蒙古"},
        {k:
"辽宁",v:"辽宁"},
        {k:
"吉林",v:"吉林"},
        {k:
"黑龙江",v:"黑龙江"},
        {k:
"安徽",v:"安徽"},
        {k:
"福建",v:"福建"},
        {k:
"江西",v:"江西"},
        {k:
"河南",v:"河南"},
        {k:
"湖南",v:"湖南"},
        {k:
"广西",v:"广西"},
        {k:
"湖北",v:"湖北"},
        {k:
"陕西",v:"陕西"},
        {k:
"新疆",v:"新疆"},
        {k:
"青海",v:"青海"},
        {k:
"宁夏",v:"宁夏"},
        {k:
"甘肃",v:"甘肃"},
        {k:
"西藏",v:"西藏"},
        {k:
"云南",v:"云南"},
        {k:
"海南",v:"海南"},
        {k:
"贵州",v:"贵州"},
        {k:
"香港",v:"香港"},
        {k:
"澳门",v:"澳门"},
        {k:
"台湾",v:"台湾"}],
    
/** 城市数据 */    
    c : [
        {k:
"上海",v:"上海"},
        {k:
"北京",v:"北京"},
        {k:
"广州",v:"广东"},
        {k:
"汕尾",v:"广东"},
        {k:
"阳江",v:"广东"},
        {k:
"揭阳",v:"广东"},
        {k:
"茂名",v:"广东"},
        {k:
"江门",v:"广东"},
        {k:
"韶关",v:"广东"},
        {k:
"惠州",v:"广东"},
        {k:
"梅州",v:"广东"},
        {k:
"汕头",v:"广东"},
        {k:
"深圳",v:"广东"},
        {k:
"珠海",v:"广东"},
        {k:
"佛山",v:"广东"},
        {k:
"肇庆",v:"广东"},
        {k:
"湛江",v:"广东"},
        {k:
"中山",v:"广东"},
        {k:
"河源",v:"广东"},
        {k:
"清远",v:"广东"},
        {k:
"云浮",v:"广东"},
        {k:
"潮州",v:"广东"},
        {k:
"东莞",v:"广东"},
        {k:
"南京",v:"江苏"},
        {k:
"无锡",v:"江苏"},
        {k:
"镇江",v:"江苏"},
        {k:
"苏州",v:"江苏"},
        {k:
"南通",v:"江苏"},
        {k:
"扬州",v:"江苏"},
        {k:
"盐城",v:"江苏"},
        {k:
"徐州",v:"江苏"},
        {k:
"淮阴",v:"江苏"},
        {k:
"连云",v:"江苏"},
        {k:
"常州",v:"江苏"},
        {k:
"泰州",v:"江苏"},
        {k:
"宿迁",v:"江苏"},
        {k:
"衢州",v:"浙江"},
        {k:
"杭州",v:"浙江"},
        {k:
"湖州",v:"浙江"},
        {k:
"嘉兴",v:"浙江"},
        {k:
"宁波",v:"浙江"},
        {k:
"绍兴",v:"浙江"},
        {k:
"台州",v:"浙江"},
        {k:
"温州",v:"浙江"},
        {k:
"丽水",v:"浙江"},
        {k:
"金华",v:"浙江"},
        {k:
"舟山",v:"浙江"},
        {k:
"菏泽",v:"山东"},
        {k:
"济南",v:"山东"},
        {k:
"青岛",v:"山东"},
        {k:
"淄博",v:"山东"},
        {k:
"德州",v:"山东"},
        {k:
"烟台",v:"山东"},
        {k:
"潍坊",v:"山东"},
        {k:
"济宁",v:"山东"},
        {k:
"泰安",v:"山东"},
        {k:
"临沂",v:"山东"},
        {k:
"滨州",v:"山东"},
        {k:
"东营",v:"山东"},
        {k:
"威海",v:"山东"},
        {k:
"枣庄",v:"山东"},
        {k:
"日照",v:"山东"},
        {k:
"莱芜",v:"山东"},
        {k:
"聊城",v:"山东"},
        {k:
"天津",v:"天津"},
        {k:
"重庆",v:"重庆"},
        {k:
"成都",v:"四川"},
        {k:
"攀枝花",v:"四川"},
        {k:
"自贡",v:"四川"},
        {k:
"绵阳",v:"四川"},
        {k:
"南充",v:"四川"},
        {k:
"达州",v:"四川"},
        {k:
"遂宁",v:"四川"},
        {k:
"广安",v:"四川"},
        {k:
"巴中(巴州)",v:"四川"},
        {k:
"泸州",v:"四川"},
        {k:
"宜宾",v:"四川"},
        {k:
"内江",v:"四川"},
        {k:
"乐山",v:"四川"},
        {k:
"凉山彝族",v:"四川"},
        {k:
"雅安",v:"四川"},
        {k:
"甘孜藏族",v:"四川"},
        {k:
"阿坝藏族羌族",v:"四川"},
        {k:
"德阳",v:"四川"},
        {k:
"广元",v:"四川"},
        {k:
"邯郸",v:"河北"},
        {k:
"石家庄",v:"河北"},
        {k:
"保定",v:"河北"},
        {k:
"张家口",v:"河北"},
        {k:
"承德",v:"河北"},
        {k:
"唐山",v:"河北"},
        {k:
"廊坊",v:"河北"},
        {k:
"沧州",v:"河北"},
        {k:
"衡水",v:"河北"},
        {k:
"邢台",v:"河北"},
        {k:
"秦皇岛",v:"河北"},
        {k:
"朔州",v:"山西"},
        {k:
"忻州",v:"山西"},
        {k:
"太原",v:"山西"},
        {k:
"大同",v:"山西"},
        {k:
"阳泉",v:"山西"},
        {k:
"晋中",v:"山西"},
        {k:
"长治",v:"山西"},
        {k:
"晋城",v:"山西"},
        {k:
"临汾",v:"山西"},
        {k:
"吕梁地区",v:"山西"},
        {k:
"运城",v:"山西"},
        {k:
"呼伦贝尔",v:"内蒙古"},
        {k:
"呼和浩特",v:"内蒙古"},
        {k:
"包头",v:"内蒙古"},
        {k:
"乌海",v:"内蒙古"},
        {k:
"乌兰察布盟",v:"内蒙古"},
        {k:
"通辽",v:"内蒙古"},
        {k:
"赤峰",v:"内蒙古"},
        {k:
"鄂尔多斯",v:"内蒙古"},
        {k:
"巴彦淖尔盟",v:"内蒙古"},
        {k:
"锡林郭勒盟",v:"内蒙古"},
        {k:
"兴安盟(乌兰浩特市)",v:"内蒙古"},
        {k:
"阿拉善盟",v:"内蒙古"},
        {k:
"沈阳",v:"辽宁"},
        {k:
"铁岭",v:"辽宁"},
        {k:
"大连",v:"辽宁"},
        {k:
"鞍山",v:"辽宁"},
        {k:
"抚顺",v:"辽宁"},
        {k:
"本溪",v:"辽宁"},
        {k:
"丹东",v:"辽宁"},
        {k:
"锦州",v:"辽宁"},
        {k:
"营口",v:"辽宁"},
        {k:
"阜新",v:"辽宁"},
        {k:
"辽阳",v:"辽宁"},
        {k:
"朝阳",v:"辽宁"},
        {k:
"盘锦",v:"辽宁"},
        {k:
"葫芦岛",v:"辽宁"},
        {k:
"长春",v:"吉林"},
        {k:
"吉林",v:"吉林"},
        {k:
"延边朝鲜族",v:"吉林"},
        {k:
"四平",v:"吉林"},
        {k:
"通化",v:"吉林"},
        {k:
"白城",v:"吉林"},
        {k:
"辽源",v:"吉林"},
        {k:
"松原",v:"吉林"},
        {k:
"白山",v:"吉林"},
        {k:
"哈尔滨",v:"黑龙江"},
        {k:
"齐齐哈尔",v:"黑龙江"},
        {k:
"牡丹江",v:"黑龙江"},
        {k:
"佳木斯",v:"黑龙江"},
        {k:
"绥化",v:"黑龙江"},
        {k:
"黑河",v:"黑龙江"},
        {k:
"大兴安岭地区",v:"黑龙江"},
        {k:
"伊春",v:"黑龙江"},
        {k:
"大庆",v:"黑龙江"},
        {k:
"七台河",v:"黑龙江"},
        {k:
"鸡西",v:"黑龙江"},
        {k:
"鹤岗",v:"黑龙江"},
        {k:
"双鸭山",v:"黑龙江"},
        {k:
"滁州",v:"安徽"},
        {k:
"合肥",v:"安徽"},
        {k:
"蚌埠",v:"安徽"},
        {k:
"芜湖",v:"安徽"},
        {k:
"淮南",v:"安徽"},
        {k:
"马鞍山",v:"安徽"},
        {k:
"安庆",v:"安徽"},
        {k:
"宿州",v:"安徽"},
        {k:
"阜阳",v:"安徽"},
        {k:
"黄山",v:"安徽"},
        {k:
"淮北",v:"安徽"},
        {k:
"铜陵",v:"安徽"},
        {k:
"宣城",v:"安徽"},
        {k:
"六安",v:"安徽"},
        {k:
"巢湖",v:"安徽"},
        {k:
"池州",v:"安徽"},
        {k:
"福州",v:"福建"},
        {k:
"厦门",v:"福建"},
        {k:
"宁德",v:"福建"},
        {k:
"莆田",v:"福建"},
        {k:
"泉州",v:"福建"},
        {k:
"漳州",v:"福建"},
        {k:
"龙岩",v:"福建"},
        {k:
"三明",v:"福建"},
        {k:
"南平",v:"福建"},
        {k:
"鹰潭",v:"江西"},
        {k:
"新余",v:"江西"},
        {k:
"南昌",v:"江西"},
        {k:
"九江",v:"江西"},
        {k:
"上饶",v:"江西"},
        {k:
"抚州",v:"江西"},
        {k:
"宜春",v:"江西"},
        {k:
"吉安",v:"江西"},
        {k:
"赣州",v:"江西"},
        {k:
"景德镇",v:"江西"},
        {k:
"萍乡",v:"江西"},
        {k:
"商丘",v:"河南"},
        {k:
"郑州",v:"河南"},
        {k:
"安阳",v:"河南"},
        {k:
"新乡",v:"河南"},
        {k:
"许昌",v:"河南"},
        {k:
"平顶山",v:"河南"},
        {k:
"信阳",v:"河南"},
        {k:
"南阳",v:"河南"},
        {k:
"开封",v:"河南"},
        {k:
"洛阳",v:"河南"},
        {k:
"焦作",v:"河南"},
        {k:
"鹤壁",v:"河南"},
        {k:
"濮阳",v:"河南"},
        {k:
"周口",v:"河南"},
        {k:
"漯河",v:"河南"},
        {k:
"驻马店",v:"河南"},
        {k:
"三门峡",v:"河南"},
        {k:
"岳阳",v:"湖南"},
        {k:
"长沙",v:"湖南"},
        {k:
"湘潭",v:"湖南"},
        {k:
"株洲",v:"湖南"},
        {k:
"衡阳",v:"湖南"},
        {k:
"郴州",v:"湖南"},
        {k:
"常德",v:"湖南"},
        {k:
"益阳",v:"湖南"},
        {k:
"娄底",v:"湖南"},
        {k:
"邵阳",v:"湖南"},
        {k:
"湘西土家族苗族",v:"湖南"},
        {k:
"张家界",v:"湖南"},
        {k:
"怀化",v:"湖南"},
        {k:
"永州",v:"湖南"},
        {k:
"防城港",v:"广西"},
        {k:
"南宁",v:"广西"},
        {k:
"柳州地区",v:"广西"},
        {k:
"桂林",v:"广西"},
        {k:
"梧州",v:"广西"},
        {k:
"贵港",v:"广西"},
        {k:
"百色",v:"广西"},
        {k:
"钦州",v:"广西"},
        {k:
"河池",v:"广西"},
        {k:
"北海",v:"广西"},
        {k:
"武汉",v:"湖北"},
        {k:
"襄樊",v:"湖北"},
        {k:
"鄂州",v:"湖北"},
        {k:
"孝感",v:"湖北"},
        {k:
"黄冈",v:"湖北"},
        {k:
"黄石",v:"湖北"},
        {k:
"咸宁",v:"湖北"},
        {k:
"荆州",v:"湖北"},
        {k:
"宜昌",v:"湖北"},
        {k:
"恩施土家族苗族",v:"湖北"},
        {k:
"十堰",v:"湖北"},
        {k:
"随州",v:"湖北"},
        {k:
"荆门",v:"湖北"},
        {k:
"天门",v:"湖北"},
        {k:
"西安",v:"陕西"},
        {k:
"咸阳",v:"陕西"},
        {k:
"延安",v:"陕西"},
        {k:
"榆林",v:"陕西"},
        {k:
"渭南",v:"陕西"},
        {k:
"商洛",v:"陕西"},
        {k:
"安康",v:"陕西"},
        {k:
"汉中",v:"陕西"},
        {k:
"宝鸡",v:"陕西"},
        {k:
"铜川",v:"陕西"},
        {k:
"塔城地区",v:"新疆"},
        {k:
"哈密地区",v:"新疆"},
        {k:
"和田地区",v:"新疆"},
        {k:
"阿勒泰地区",v:"新疆"},
        {k:
"克孜勒苏柯尔克孜",v:"新疆"},
        {k:
"博尔塔拉蒙古",v:"新疆"},
        {k:
"克拉玛依",v:"新疆"},
        {k:
"乌鲁木齐",v:"新疆"},
        {k:
"奎屯",v:"新疆"},
        {k:
"石河子",v:"新疆"},
        {k:
"昌吉回族",v:"新疆"},
        {k:
"吐鲁番地区",v:"新疆"},
        {k:
"巴音郭楞蒙古",v:"新疆"},
        {k:
"阿克苏地区",v:"新疆"},
        {k:
"喀什地区",v:"新疆"},
        {k:
"伊犁哈萨克",v:"新疆"},
        {k:
"海北藏族",v:"青海"},
        {k:
"西宁",v:"青海"},
        {k:
"海东地区",v:"青海"},
        {k:
"黄南藏族",v:"青海"},
        {k:
"海南藏族",v:"青海"},
        {k:
"果洛藏族",v:"青海"},
        {k:
"玉树藏族",v:"青海"},
        {k:
"海西蒙古族藏族",v:"青海"},
        {k:
"格尔木",v:"青海"},
        {k:
"银川",v:"宁夏"},
        {k:
"石嘴山",v:"宁夏"},
        {k:
"吴忠",v:"宁夏"},
        {k:
"固原",v:"宁夏"},
        {k:
"临夏回族",v:"甘肃"},
        {k:
"兰州",v:"甘肃"},
        {k:
"定西地区",v:"甘肃"},
        {k:
"平凉地区",v:"甘肃"},
        {k:
"庆阳地区",v:"甘肃"},
        {k:
"金昌",v:"甘肃"},
        {k:
"张掖",v:"甘肃"},
        {k:
"酒泉",v:"甘肃"},
        {k:
"天水",v:"甘肃"},
        {k:
"陇南地区",v:"甘肃"},
        {k:
"甘南藏族",v:"甘肃"},
        {k:
"白银",v:"甘肃"},
        {k:
"拉萨",v:"西藏"},
        {k:
"日喀则地区",v:"西藏"},
        {k:
"山南地区",v:"西藏"},
        {k:
"林芝地区",v:"西藏"},
        {k:
"昌都地区",v:"西藏"},
        {k:
"那曲地区",v:"西藏"},
        {k:
"阿里地区",v:"西藏"},
        {k:
"西双版纳傣族",v:"云南"},
        {k:
"德宏傣族景颇族",v:"云南"},
        {k:
"昭通",v:"云南"},
        {k:
"昆明",v:"云南"},
        {k:
"大理白族",v:"云南"},
        {k:
"红河哈尼族彝族",v:"云南"},
        {k:
"曲靖",v:"云南"},
        {k:
"保山",v:"云南"},
        {k:
"文山壮族苗族",v:"云南"},
        {k:
"玉溪",v:"云南"},
        {k:
"楚雄彝族",v:"云南"},
        {k:
"思茅地区",v:"云南"},
        {k:
"临沧地区",v:"云南"},
        {k:
"怒江傈僳族",v:"云南"},
        {k:
"迪庆藏族",v:"云南"},
        {k:
"丽江地区",v:"云南"},
        {k:
"海口",v:"海南"},
        {k:
"贵阳",v:"贵州"},
        {k:
"遵义",v:"贵州"},
        {k:
"安顺",v:"贵州"},
        {k:
"黔南布依族苗族",v:"贵州"},
        {k:
"黔东南苗族侗族",v:"贵州"},
        {k:
"铜仁地区",v:"贵州"},
        {k:
"毕节地区",v:"贵州"},
        {k:
"六盘水",v:"贵州"},
        {k:
"黔西南布依族苗族",v:"贵州"},
        {k:
"香港",v:"香港"},
        {k:
"澳门",v:"澳门"},
        {k:
"台湾",v:"台湾"}],
        
    
/** 初始化SELECT */
    __initSel : 
function (oKeyValues, oSel, initValue) 
    {
        oSel.length 
= 0;
        
for(var i=0;i<oKeyValues.length; i=i+1)
        {
            
var oKeyValue = oKeyValues[i];
            
var oOption = document.createElement("option");
            oOption.value 
= oKeyValue.k;
            
if(oKeyValue.k == initValue)
            {
                oOption.selected 
= true;
            }
            
var oText = document.createTextNode(oKeyValue.k);
            oOption.appendChild(oText);
            oSel.appendChild(oOption);
        }
    },
    
/** 初始化省份 */
    initProvince : 
function (firstStageSelId, initValue)
    {
        
var oSel = document.getElementById(firstStageSelId);
        
//alert(oSel.id);
        this.__initSel(this.p, oSel, initValue);
    },
    
/** 初始化城市 */
    initCity : 
function (firstStageSelId,secondStageSelId,initValue)
    {
        
var oSelFirstStage = document.getElementById(firstStageSelId);
        
var oSelSecondStage = document.getElementById(secondStageSelId);
        
var aTempKeyValus = new Array();
        
for(var i=0;i<this.c.length;i=i+1)
        {
            
if(this.c[i].v == oSelFirstStage.value)
            {
                aTempKeyValus.push(
this.c[i]);
            }
        }
        
this.__initSel(aTempKeyValus, oSelSecondStage, initValue);
    }
};
    
    




   


使用方法:
 1.<select name="areaProvince" id="areaProvince" class="text" onchange="PC.initCity('areaProvince','areaCity','');">
                  </select><select name="areaCity" id="areaCity" class="text"></select>
 2.在</body>前面加<script type="text/javascript"> PC.initProvince("areaProvince","上海");PC.initCity("areaProvince","areaCity","上海");</script>
posted on 2009-01-13 19:46 HUIKK 阅读(1197) 评论(1)  编辑  收藏 所属分类: JavaScript

评论

# re: 省份 城市 javascript 2009-07-02 19:16 da网
谢谢楼主,这个不错,好用啊  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: