/* 所有大类对象列表 */ var bigtypes = new Array(); /* 全局方法 - 根据大类id 获得小类对象列表 */ function getSmalltypes(id) { for (var i =0, c = bigtypes.length; i < c; ++i) { if (bigtypes[i].id == id) { bigtypes[i].name; return bigtypes[i].smalltypes; } } return new Array(); } /* 大类对象 */ /* Bigtype constructor */ function Bigtype(id, name) { this.id = id; this.name = name; this.smalltypes = new Array(); this.addSmalltype = addSmalltype; } /* 增加一个小类 */ function addSmalltype(id, name) { var st = new Smalltype(id, name); this.smalltypes[this.smalltypes.length] = st; } /* 小类对象*/ /* Smalltype constructor */ function Smalltype(id, name) { this.id = id; this.name = name; } /* 设置选择大类的相应小类 */ function selBigtype(bt, st) { var bigtypeId = bt.options[bt.selectedIndex].value; // 清除小类旧数据 for (var i = st.length - 1; i >= 0; i--) { st.options[i] = null; } // 增加小类新数据 var smalltypes = getSmalltypes(bigtypeId); for (var i = 0, c = smalltypes.length; i < c; ++i) { var opt = new Option(smalltypes[i].name, smalltypes[i].id, 0, 0); st.options[st.options.length] = opt; } } /* 初始化所有分类数据 */ function init() { //!!! 检查重复初始化 if (bigtypes.length > 0) { return; } var bigtype = null; bigtype = new Bigtype(165,"安徽"); bigtype.addSmalltype("11","黄山市"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(151,"福建"); bigtype.addSmalltype("30","福州"); bigtype.addSmalltype("32","厦门"); bigtype.addSmalltype("33","泉州"); bigtype.addSmalltype("34","武夷山"); bigtype.addSmalltype("35","龙岩"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(154,"甘肃"); bigtype.addSmalltype(0,"暂无小类"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(155,"贵州"); bigtype.addSmalltype("29","贵阳"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(156,"云南"); bigtype.addSmalltype(0,"暂无小类"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(157,"湖南"); bigtype.addSmalltype("25","张家界"); bigtype.addSmalltype("26","郴州"); bigtype.addSmalltype("27","岳阳"); bigtype.addSmalltype("28","湘潭"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(158,"江西"); bigtype.addSmalltype("36","南昌"); bigtype.addSmalltype("37","赣州"); bigtype.addSmalltype("38","婺源"); bigtype.addSmalltype("46","三清山"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(161,"海南"); bigtype.addSmalltype("10","三亚"); bigtype.addSmalltype("45","儋州"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(162,"湖北"); bigtype.addSmalltype(0,"暂无小类"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(164,"广西"); bigtype.addSmalltype("7","桂林"); bigtype.addSmalltype("8","玉林"); bigtype.addSmalltype("9","德天"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(176,"西藏"); bigtype.addSmalltype(0,"暂无小类"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(166,"越南"); bigtype.addSmalltype(0,"暂无小类"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(167,"山东"); bigtype.addSmalltype("39","泰安"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(168,"山西"); bigtype.addSmalltype(0,"暂无小类"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(170,"黑龙江"); bigtype.addSmalltype(0,"暂无小类"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(171,"国外"); bigtype.addSmalltype("44","马来西亚"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(172,"四川"); bigtype.addSmalltype("40","九寨沟"); bigtype.addSmalltype("41","稻城"); bigtype.addSmalltype("42","坝上"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(173,"新疆"); bigtype.addSmalltype(0,"暂无小类"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(174,"澳门"); bigtype.addSmalltype(0,"暂无小类"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(175,"香港"); bigtype.addSmalltype("43","迪士尼"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(163,"北京"); bigtype.addSmalltype(0,"暂无小类"); bigtypes[bigtypes.length] = bigtype; bigtype = new Bigtype(149,"广东"); bigtype.addSmalltype("12","韶关"); bigtype.addSmalltype("13","河源"); bigtype.addSmalltype("14","清远"); bigtype.addSmalltype("15","汕头"); bigtype.addSmalltype("16","广州"); bigtype.addSmalltype("17","肇庆"); bigtype.addSmalltype("18","梅州"); bigtype.addSmalltype("19","潮州"); bigtype.addSmalltype("20","惠州"); bigtype.addSmalltype("21","汕尾"); bigtype.addSmalltype("22","湛江"); bigtype.addSmalltype("23","茂名"); bigtype.addSmalltype("24","阳江"); bigtypes[bigtypes.length] = bigtype; }