javascript技巧

关注公众号 jb51net

关闭
首页 > 网络编程 > JavaScript > javascript技巧 > 省市联动

js实现省市联动效果的简单实例

作者:

本篇文章主要是对js实现省市联动效果的简单实例进行了介绍,需要的朋友可以过来,希望对大家有所帮助
实例如下:
复制代码 代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>省市二级联动菜单</title>
    <script type="text/javascript">
var _City_1 = ["100101:/u6d77/u6dc0/u533a", "110102:/u671d/u9633/u533a", "100103:/u4e1c/u57ce/u533a", "100104:/u897f/u57ce/u533a", "100105:/u5d07/u6587/u533a", "100106:/u5ba3/u6b66/u533a", "100107:/u4e30/u53f0/u533a", "100108:/u77f3/u666f/u5c71/u533a", "100109:/u95e8/u5934/u6c9f/u533a", "100110:/u623f/u5c71/u533a", "100111:/u901a/u5dde/u533a", "100112:/u987a/u4e49/u533a", "100113:/u660c/u5e73/u533a", "100114:/u5927/u5174/u533a", "100115:/u6000/u67d4/u533a", "100116:/u5e73/u8c37/u533a", "100201:/u5bc6/u4e91/u53bf", "100202:/u5ef6/u5e86/u53bf"], _City_2 = ["200101:/u9ec4/u6d66/u533a", "200102:/u5362/u6e7e/u533a", "200103:/u5f90/u6c47/u533a", "200104:/u957f/u5b81/u533a", "200105:/u9759/u5b89/u533a", "200106:/u666e/u9640/u533a", "200107:/u95f8/u5317/u533a", "200108:/u8679/u53e3/u533a", "200109:/u6768/u6d66/u533a", "200110:/u95f5/u884c/u533a", "200111:/u5b9d/u5c71/u533a", "200112:/u5609/u5b9a/u533a", "200113:/u6d66/u4e1c/u65b0/u533a", "200114:/u91d1/u5c71/u533a", "200115:/u677e/u6c5f/u533a", "200116:/u9752/u6d66/u533a", "200117:/u5357/u6c47/u533a", "200118:/u5949/u8d24/u533a", "200201:/u5d07/u660e/u53bf"], _City_3 = ["300104:/u5357/u5f00/u533a", "300101:/u548c/u5e73/u533a", "300102:/u6cb3/u4e1c/u533a", "300103:/u6cb3/u897f/u533a", "300105:/u6cb3/u5317/u533a", "300106:/u7ea2/u6865/u533a", "300107:/u5858/u6cbd/u533a", "300108:/u6c49/u6cbd/u533a", "300109:/u5927/u6e2f/u533a", "300110:/u4e1c/u4e3d/u533a", "300111:/u897f/u9752/u533a", "300112:/u6d25/u5357/u533a", "300113:/u5317/u8fb0/u533a", "300114:/u6b66/u6e05/u533a", "300115:/u5b9d/u577b/u533a", "300201:/u5b81/u6cb3/u53bf", "300202:/u9759/u6d77/u53bf", "300203:/u84df/u53bf"], _City_4 = ["400101:/u4e07/u5dde/u533a", "400102:/u6daa/u9675/u533a", "400103:/u6e1d/u4e2d/u533a", "400104:/u5927/u6e21/u53e3/u533a", "400105:/u6c5f/u5317/u533a", "400106:/u6c99/u576a/u575d/u533a", "400107:/u4e5d/u9f99/u5761/u533a", "400108:/u5357/u5cb8/u533a", "400109:/u5317/u789a/u533a", "400110:/u4e07/u76db/u533a", "400111:/u53cc/u6865/u533a", "400112:/u6e1d/u5317/u533a", "400113:/u5df4/u5357/u533a", "400114:/u9ed4/u6c5f/u533a", "400115:/u957f/u5bff/u533a", "400116:/u6c5f/u6d25/u533a", "400117:/u5408/u5ddd/u533a", "400118:/u6c38/u5ddd/u533a", "400119:/u5357/u5ddd/u533a", "400201:/u7da6/u6c5f/u53bf", "400202:/u6f7c/u5357/u53bf", "400203:/u94dc/u6881/u53bf", "400204:/u5927/u8db3/u53bf", "400205:/u8363/u660c/u53bf", "400206:/u74a7/u5c71/u53bf", "400207:/u6881/u5e73/u53bf", "400208:/u57ce/u53e3/u53bf", "400209:/u4e30/u90fd/u53bf", "400210:/u57ab/u6c5f/u53bf", "400211:/u6b66/u9686/u53bf", "400212:/u5fe0/u53bf", "400213:/u5f00/u53bf", "400214:/u4e91/u9633/u53bf", "400215:/u5949/u8282/u53bf", "400216:/u5deb/u5c71/u53bf", "400217:/u5deb/u6eaa/u53bf", "400218:/u77f3/u67f1/u571f/u5bb6/u65cf/u81ea/u6cbb/u53bf", "400219:/u79c0/u5c71/u571f/u5bb6/u65cf/u82d7/u65cf/u81ea/u6cbb/u53bf", "400220:/u9149/u9633/u571f/u5bb6/u65cf/u82d7/u65cf/u81ea/u6cbb/u53bf", "400221:/u5f6d/u6c34/u82d7/u65cf/u571f/u5bb6/u65cf/u81ea/u6cbb/u53bf"], _City_5 = ["150001:/u54c8/u5c14/u6ee8/u5e02", "150002:/u7ee5/u5316/u5e02", "150003:/u9f50/u9f50/u54c8/u5c14/u5e02", "150004:/u7261/u4e39/u6c5f/u5e02", "150005:/u4f0a/u6625/u5e02", "150006:/u4f73/u6728/u65af/u5e02", "150007:/u9e21/u897f/u5e02", "150008:/u9e64/u5c97/u5e02", "150009:/u53cc/u9e2d/u5c71/u5e02", "150010:/u5927/u5e86/u5e02", "150011:/u4e03/u53f0/u6cb3/u5e02", "150012:/u9ed1/u6cb3/u5e02", "150101:/u5927/u5174/u5b89/u5cad/u5730/u533a"], _City_6 = ["130001:/u957f/u6625/u5e02", "130002:/u5409/u6797/u5e02", "130003:/u56db/u5e73/u5e02", "130004:/u8fbd/u6e90/u5e02", "130005:/u901a/u5316/u5e02", "130006:/u767d/u5c71/u5e02", "130007:/u677e/u539f/u5e02", "130008:/u767d/u57ce/u5e02", "130101:/u5ef6/u8fb9/u671d/u9c9c/u65cf/u81ea/u6cbb/u5dde"], _City_7 = ["110001:/u6c88/u9633/u5e02", "110002:/u5927/u8fde/u5e02", "110003:/u978d/u5c71/u5e02", "110004:/u629a/u987a/u5e02", "110005:/u672c/u6eaa/u5e02", "110006:/u4e39/u4e1c/u5e02", "110007:/u9526/u5dde/u5e02", "110008:/u8425/u53e3/u5e02", "110009:/u961c/u65b0/u5e02", "110010:/u8fbd/u9633/u5e02", "110011:/u76d8/u9526/u5e02", "110012:/u94c1/u5cad/u5e02", "110013:/u671d/u9633/u5e02", "110014:/u846b/u82a6/u5c9b/u5e02"], _City_8 = ["250001:/u6d4e/u5357/u5e02", "250002:/u9752/u5c9b/u5e02", "250003:/u6dc4/u535a/u5e02", "250004:/u67a3/u5e84/u5e02", "250005:/u4e1c/u8425/u5e02", "250006:/u70df/u53f0/u5e02", "250007:/u6f4d/u574a/u5e02", "250008:/u6d4e/u5b81/u5e02", "250009:/u6cf0/u5b89/u5e02", "250010:/u5a01/u6d77/u5e02", "250011:/u65e5/u7167/u5e02", "250012:/u83b1/u829c/u5e02", "250013:/u4e34/u6c82/u5e02", "250014:/u5fb7/u5dde/u5e02", "250015:/u804a/u57ce/u5e02", "250016:/u6ee8/u5dde/u5e02", "250017:/u83cf/u6cfd/u5e02"], _City_9 = ["030001:/u592a/u539f/u5e02", "030002:/u5927/u540c/u5e02", "030003:/u9633/u6cc9/u5e02", "030004:/u957f/u6cbb/u5e02", "030005:/u664b/u57ce/u5e02", "030006:/u6714/u5dde/u5e02", "030007:/u664b/u4e2d/u5e02", "030008:/u8fd0/u57ce/u5e02", "030009:/u5ffb/u5dde/u5e02", "030010:/u4e34/u6c7e/u5e02", "030011:/u5415/u6881/u5e02"], _City_10 = ["710001:/u897f/u5b89/u5e02", "710002:/u94dc/u5ddd/u5e02", "710003:/u5b9d/u9e21/u5e02", "710004:/u54b8/u9633/u5e02", "710005:/u6e2d/u5357/u5e02", "710006:/u5ef6/u5b89/u5e02", "710007:/u6c49/u4e2d/u5e02", "710008:/u6986/u6797/u5e02", "710009:/u5b89/u5eb7/u5e02", "710010:/u5546/u6d1b/u5e02"], _City_11 = ["050001:/u77f3/u5bb6/u5e84/u5e02", "050002:/u5510/u5c71/u5e02", "050003:/u79e6/u7687/u5c9b/u5e02", "050004:/u90af/u90f8/u5e02", "050005:/u90a2/u53f0/u5e02", "050006:/u4fdd/u5b9a/u5e02", "050007:/u5f20/u5bb6/u53e3/u5e02", "050008:/u627f/u5fb7/u5e02", "050009:/u6ca7/u5dde/u5e02", "050010:/u5eca/u574a/u5e02", "050011:/u8861/u6c34/u5e02"], _City_12 = ["450001:/u90d1/u5dde/u5e02", "450002:/u5f00/u5c01/u5e02", "450003:/u6d1b/u9633/u5e02", "450004:/u5e73/u9876/u5c71/u5e02", "450005:/u5b89/u9633/u5e02", "450006:/u9e64/u58c1/u5e02", "450007:/u65b0/u4e61/u5e02", "450008:/u7126/u4f5c/u5e02", "450008:/u6d4e/u6e90/u5e02", "450009:/u6fee/u9633/u5e02", "450010:/u8bb8/u660c/u5e02", "450011:/u6f2f/u6cb3/u5e02", "450012:/u4e09/u95e8/u5ce1/u5e02", "450013:/u5357/u9633/u5e02", "450014:/u5546/u4e18/u5e02", "450015:/u4fe1/u9633/u5e02", "450016:/u5468/u53e3/u5e02", "450017:/u9a7b/u9a6c/u5e97/u5e02"], _City_13 = ["430001:/u6b66/u6c49/u5e02", "430002:/u9ec4/u77f3/u5e02", "430003:/u5341/u5830/u5e02", "430005:/u5b9c/u660c/u5e02", "430006:/u8944/u6a0a/u5e02", "430007:/u9102/u5dde/u5e02", "430008:/u8346/u95e8/u5e02", "430009:/u5b5d/u611f/u5e02", "430010:/u8346/u5dde/u5e02", "430011:/u9ec4/u5188/u5e02", "430012:/u54b8/u5b81/u5e02", "430013:/u968f/u5dde/u5e02", "430014:/u4ed9/u6843/u5e02", "430015:/u6f5c/u6c5f/u5e02", "430016:/u5929/u95e8/u5e02", "430101:/u6069/u65bd/u571f/u5bb6/u65cf/u82d7/u65cf/u81ea/u6cbb/u5dde", "430102:/u795e/u519c/u67b6/u6797/u533a"], _City_14 = ["430001:/u957f/u6c99/u5e02", "430002:/u682a/u6d32/u5e02", "430003:/u6e58/u6f6d/u5e02", "430004:/u8861/u9633/u5e02", "430005:/u90b5/u9633/u5e02", "430006:/u5cb3/u9633/u5e02", "430007:/u5e38/u5fb7/u5e02", "430008:/u5f20/u5bb6/u754c/u5e02", "430009:/u76ca/u9633/u5e02", "430010:/u90f4/u5dde/u5e02", "430011:/u6c38/u5dde/u5e02", "430012:/u6000/u5316/u5e02", "430013:/u5a04/u5e95/u5e02", "430101:/u6e58/u897f/u571f/u5bb6/u65cf/u82d7/u65cf/u81ea/u6cbb/u5dde"], _City_15 = ["570001:/u6d77/u53e3/u5e02", "570002:/u4e09/u4e9a/u5e02", "570003:/u4e94/u6307/u5c71/u5e02", "570004:/u743c/u6d77/u5e02", "570005:/u510b/u5dde/u5e02", "570006:/u6587/u660c/u5e02", "570007:/u4e07/u5b81/u5e02", "570008:/u4e1c/u65b9/u5e02"], _City_16 = ["210001:/u5357/u4eac/u5e02", "210002:/u65e0/u9521/u5e02", "210003:/u5f90/u5dde/u5e02", "210004:/u5e38/u5dde/u5e02", "210005:/u82cf/u5dde/u5e02", "210006:/u5357/u901a/u5e02", "210007:/u8fde/u4e91/u6e2f/u5e02", "210008:/u6dee/u5b89/u5e02", "210009:/u76d0/u57ce/u5e02", "210010:/u626c/u5dde/u5e02", "210011:/u9547/u6c5f/u5e02", "210012:/u6cf0/u5dde/u5e02", "210013:/u5bbf/u8fc1/u5e02"], _City_17 = ["330001:/u5357/u660c/u5e02", "330002:/u666f/u5fb7/u9547/u5e02", "330003:/u840d/u4e61/u5e02", "330004:/u4e5d/u6c5f/u5e02", "330005:/u65b0/u4f59/u5e02", "330006:/u9e70/u6f6d/u5e02", "330007:/u8d63/u5dde/u5e02", "330008:/u5409/u5b89/u5e02", "330009:/u5b9c/u6625/u5e02", "330010:/u629a/u5dde/u5e02", "330011:/u4e0a/u9976/u5e02"], _City_18 = ["510001:/u5e7f/u5dde/u5e02", "510002:/u97f6/u5173/u5e02", "510003:/u6df1/u5733/u5e02", "510004:/u73e0/u6d77/u5e02", "510005:/u6c55/u5934/u5e02", "510006:/u4f5b/u5c71/u5e02", "510007:/u6c5f/u95e8/u5e02", "510008:/u6e5b/u6c5f/u5e02", "510009:/u8302/u540d/u5e02", "510010:/u8087/u5e86/u5e02", "510011:/u60e0/u5dde/u5e02", "510012:/u6885/u5dde/u5e02", "510013:/u6c55/u5c3e/u5e02", "510014:/u6cb3/u6e90/u5e02", "510015:/u9633/u6c5f/u5e02", "510016:/u6e05/u8fdc/u5e02", "510017:/u4e1c/u839e/u5e02", "510018:/u4e2d/u5c71/u5e02", "510019:/u6f6e/u5dde/u5e02", "510020:/u63ed/u9633/u5e02", "510021:/u4e91/u6d6e/u5e02"], _City_19 = ["530001:/u5357/u5b81/u5e02", "530002:/u67f3/u5dde/u5e02", "530003:/u6842/u6797/u5e02", "530004:/u68a7/u5dde/u5e02", "530005:/u5317/u6d77/u5e02", "530006:/u9632/u57ce/u6e2f/u5e02", "530007:/u94a6/u5dde/u5e02", "530008:/u8d35/u6e2f/u5e02", "530009:/u7389/u6797/u5e02", "530010:/u767e/u8272/u5e02", "530011:/u8d3a/u5dde/u5e02", "530012:/u6cb3/u6c60/u5e02", "530013:/u6765/u5bbe/u5e02", "530014:/u5d07/u5de6/u5e02"], _City_20 = ["650001:/u6606/u660e/u5e02", "650003:/u66f2/u9756/u5e02", "650004:/u7389/u6eaa/u5e02", "650005:/u4fdd/u5c71/u5e02", "650006:/u662d/u901a/u5e02", "650007:/u4e3d/u6c5f/u5e02", "650008:/u601d/u8305/u5e02", "650009:/u4e34/u6ca7/u5e02"], _City_21 = ["550001:/u8d35/u9633/u5e02", "550002:/u516d/u76d8/u6c34/u5e02", "550003:/u9075/u4e49/u5e02", "550004:/u5b89/u987a/u5e02", "5500101:/u94dc/u4ec1/u5730/u533a", "550102:/u6bd5/u8282/u5730/u533a"], _City_22 = ["610001:/u6210/u90fd/u5e02", "610002:/u81ea/u8d21/u5e02", "610003:/u6500/u679d/u82b1/u5e02", "610004:/u6cf8/u5dde/u5e02", "610005:/u5fb7/u9633/u5e02", "610006:/u7ef5/u9633/u5e02", "610007:/u5e7f/u5143/u5e02", "610008:/u9042/u5b81/u5e02", "610009:/u5185/u6c5f/u5e02", "610010:/u4e50/u5c71/u5e02", "610011:/u5357/u5145/u5e02", "610012:/u7709/u5c71/u5e02", "610013:/u5b9c/u5bbe/u5e02", "610014:/u5e7f/u5b89/u5e02", "610015:/u8fbe/u5dde/u5e02", "610016:/u96c5/u5b89/u5e02", "610017:/u5df4/u4e2d/u5e02", "610018:/u8d44/u9633/u5e02", "610101:/u963f/u575d/u85cf/u65cf/u7f8c/u65cf/u81ea/u6cbb/u5dde", "610102:/u7518/u5b5c/u85cf/u65cf/u81ea/u6cbb/u5dde", "610103:/u51c9/u5c71/u5f5d/u65cf/u81ea/u6cbb/u5dde"], _City_23 = ["010001:/u547c/u548c/u6d69/u7279/u5e02", "010002:/u5305/u5934/u5e02", "010003:/u4e4c/u6d77/u5e02", "010004:/u8d64/u5cf0/u5e02", "010005:/u901a/u8fbd/u5e02", "1010006:/u9102/u5c14/u591a/u65af/u5e02", "010007:/u547c/u4f26/u8d1d/u5c14/u5e02", "010008:/u5df4/u5f66/u6dd6/u5c14/u5e02", "010009:/u4e4c/u5170/u5bdf/u5e03/u5e02", "010101:/u5174/u5b89/u76df", "010102:/u9521/u6797/u90ed/u52d2/u76df", "010103:/u963f/u62c9/u5584/u76df"], _City_24 = ["750001:/u94f6/u5ddd/u5e02", "750002:/u77f3/u5634/u5c71/u5e02", "750003:/u5434/u5fe0/u5e02", "750004:/u56fa/u539f/u5e02", "750005:/u4e2d/u536b/u5e02"], _City_25 = ["730001:/u5170/u5dde/u5e02", "730002:/u5609/u5cea/u5173/u5e02", "730003:/u91d1/u660c/u5e02", "730004:/u767d/u94f6/u5e02", "730005:/u5929/u6c34/u5e02", "730006:/u6b66/u5a01/u5e02", "730007:/u5f20/u6396/u5e02", "730008:/u5e73/u51c9/u5e02", "730009:/u9152/u6cc9/u5e02", "730010:/u5e86/u9633/u5e02", "730011:/u5b9a/u897f/u5e02", "730012:/u9647/u5357/u5e02", "730101:/u4e34/u590f/u56de/u65cf/u81ea/u6cbb/u5dde", "730102:/u7518/u5357/u85cf/u65cf/u81ea/u6cbb/u5dde"], _City_26 = ["810001:/u897f/u5b81/u5e02", "810021:/u6d77/u4e1c/u5730/u533a", "810022:/u6d77/u5317/u85cf/u65cf/u81ea/u6cbb/u5dde", "810023:/u9ec4/u5357/u85cf/u65cf/u81ea/u6cbb/u5dde", "810025:/u6d77/u5357/u85cf/u65cf/u81ea/u6cbb/u5dde", "810026:/u679c/u6d1b/u85cf/u65cf/u81ea/u6cbb/u5dde", "810027:/u7389/u6811/u85cf/u65cf/u81ea/u6cbb/u5dde", "810028:/u6d77/u897f/u8499/u53e4/u65cf/u85cf/u65cf/u81ea/u6cbb/u5dde"], _City_27 = ["850001:/u62c9/u8428/u5e02", "850101:/u660c/u90fd/u5730/u533a", "850102:/u5c71/u5357/u5730/u533a", "850103:/u65e5/u5580/u5219/u5730/u533a", "850104:/u90a3/u66f2/u5730/u533a", "850105:/u963f/u91cc/u5730/u533a", "850106:/u6797/u829d/u5730/u533a"], _City_28 = ["830001:/u4e4c/u9c81/u6728/u9f50/u5e02", "830002:/u514b/u62c9/u739b/u4f9d/u5e02", "830003:/u77f3/u6cb3/u5b50/u5e02", "830004:/u963f/u62c9/u5c14/u5e02", "830005:/u56fe/u6728/u8212/u514b/u5e02", "830006:/u4e94/u5bb6/u6e20/u5e02", "830101:/u5410/u9c81/u756a/u5730/u533a", "830102:/u54c8/u5bc6/u5730/u533a", "830103:/u660c/u5409/u56de/u65cf/u81ea/u6cbb/u5dde", "830104:/u535a/u5c14/u5854/u62c9/u8499/u53e4/u81ea/u6cbb/u5dde", "830105:/u5df4/u97f3/u90ed/u695e/u8499/u53e4/u81ea/u6cbb/u5dde", "830106:/u963f/u514b/u82cf/u5730/u533a", "830107:/u514b/u5b5c/u52d2/u82cf/u67ef/u5c14/u514b/u5b5c/u81ea/u6cbb/u5dde", "830108:/u5580/u4ec0/u5730/u533a", "830109:/u548c/u7530/u5730/u533a", "830110:/u4f0a/u7281/u54c8/u8428/u514b/u81ea/u6cbb/u5dde", "830111:/u5854/u57ce/u5730/u533a", "830112:/u963f/u52d2/u6cf0/u5730/u533a"], _City_29 = ["230001:/u5408/u80a5/u5e02", "230002:/u829c/u6e56/u5e02", "230003:/u868c/u57e0/u5e02", "230004:/u6dee/u5357/u5e02", "230005:/u9a6c/u978d/u5c71/u5e02", "230006:/u6dee/u5317/u5e02", "230007:/u94dc/u9675/u5e02", "230008:/u5b89/u5e86/u5e02", "230010:/u9ec4/u5c71/u5e02", "230010:/u6ec1/u5dde/u5e02", "230011:/u961c/u9633/u5e02", "230012:/u5bbf/u5dde/u5e02", "230013:/u5de2/u6e56/u5e02", "230014:/u516d/u5b89/u5e02", "230015:/u4eb3/u5dde/u5e02", "230016:/u6c60/u5dde/u5e02", "230017:/u5ba3/u57ce/u5e02"], _City_30 = ["310001:/u676d/u5dde/u5e02", "310002:/u5b81/u6ce2/u5e02", "310003:/u6e29/u5dde/u5e02", "310004:/u5609/u5174/u5e02", "310005:/u6e56/u5dde/u5e02", "310006:/u7ecd/u5174/u5e02", "310007:/u91d1/u534e/u5e02", "310008:/u8862/u5dde/u5e02", "310009:/u821f/u5c71/u5e02", "310010:/u53f0/u5dde/u5e02", "310011:/u4e3d/u6c34/u5e02"], _City_31 = ["360001:/u798f/u5dde/u5e02", "360002:/u53a6/u95e8/u5e02", "360003:/u8386/u7530/u5e02", "360004:/u4e09/u660e/u5e02", "360005:/u6cc9/u5dde/u5e02", "360006:/u6f33/u5dde/u5e02", "360007:/u5357/u5e73/u5e02", "360008:/u9f99/u5ca9/u5e02", "360009:/u5b81/u5fb7/u5e02"]; function $($) { return typeof ($) == "string" ? document.getElementById($) : $ } var ProvinceCityComponent = new Object(), comProvinceElementId = 0, comCityElementId = 0; ProvinceCityComponent.init = function(C, I) { comProvinceElementId = C; comCityElementId = I; var B = ["/u5317/u4eac", "/u4e0a/u6d77", "/u5929/u6d25", "/u91cd/u5e86", "/u9ed1/u9f99/u6c5f", "/u5409/u6797", "/u8fbd/u5b81", "/u5c71/u4e1c", "/u5c71/u897f", "/u9655/u897f", "/u6cb3/u5317", "/u6cb3/u5357", "/u6e56/u5317", "/u6e56/u5357", "/u6d77/u5357", "/u6c5f/u82cf", "/u6c5f/u897f", "/u5e7f/u4e1c", "/u5e7f/u897f", "/u4e91/u5357", "/u8d35/u5dde", "/u56db/u5ddd", "/u5185/u8499/u53e4", "/u5b81/u590f", "/u7518/u8083", "/u9752/u6d77", "/u897f/u85cf", "/u65b0/u7586", "/u5b89/u5fbd", "/u6d59/u6c5f", "/u798f/u5efa"], _ = $(comProvinceElementId), D = _.selectedIndex, A = _.options, E = A.length; if (D >= 0) { try { for (var H = E; H > 1; H--) _.remove(H - 1); E = A.length; for (H = 0; H < B.length; H++) { var G = document.createElement("OPTION"); _.options.add(G); G.value = H + 1; G.text = B[H].toString() } } catch (F) { alert("[init]" + F.message) } } window.attachEvent ? $(C).attachEvent("onchange", ProvinceCityComponent.CreateCityList) : $(C).addEventListener("change", ProvinceCityComponent.CreateCityList, false) }; ProvinceCityComponent.CreateCityList = function(e) { var provinceSelectedIndex = $(comProvinceElementId).selectedIndex; if (provinceSelectedIndex >= 1 && provinceSelectedIndex <= 31) { try { var cityArr = eval("_City_" + provinceSelectedIndex), cityArrLen = cityArr.length, oCitySelect = $(comCityElementId), oColl = oCitySelect.options, oCollLen = oColl.length; for (var i = oCollLen; i > 1; i--) oCitySelect.remove(i - 1); oCollLen = oColl.length; var subArr = []; for (var j = 0; j < cityArrLen; j++) { var oOption = document.createElement("OPTION"); oCitySelect.options.add(oOption); subArr = cityArr[j].split(":"); oOption.value = subArr[0].toString(); oOption.text = subArr[1].toString() } } catch (e) { alert("[CityList]" + e.message) } } else if (provinceSelectedIndex > 0) { try { cityArr = eval("_City_" + provinceSelectedIndex), cityArrLen = cityArr.length, oCitySelect = $(comCityElementId), oColl = oCitySelect.options, oCollLen = oColl.length; for (i = oCollLen; i > 1; i--) oCitySelect.remove(i - 1); oCollLen = oColl.length; subArr = []; for (j = 0; j < cityArrLen; j++) { oOption = document.createElement("OPTION"); oCitySelect.options.add(oOption); subArr = cityArr[j].split(":"); oOption.value = subArr[0].toString(); oOption.text = subArr[1].toString() } } catch (e) { alert("[CityList]" + e.message) } } }
    </script>
</head>
<body>
   <label for="province">省</label><select id="province"><option value="0">请选择省份</option></select>
   <label for="city">市</label><select id="city"><option value="0">请选择市</option></select>
</body>
</html>
<script type="text/javascript">
    //<![CDATA[
    ProvinceCityComponent.init("province", "city");
    //]]>
</script>
您可能感兴趣的文章:
阅读全文