2012年9月13日 星期四

透過Javascript 裡 Array 的 push 方法, 改善程式的可維護性

專案裡有一個需,有一個查詢用的表單, 要允許使用者查詢台灣的縣市+鄉鎮, 而且下拉框要聯動, 很久以前, 在台灣五都整併後, 我有參考郵局網頁裡的javascript的寫法, 但是有小小的問題, 參考如下:
說明: 郵局把宜蘭出現的位置放在很下面, 我猜測應該是把宜蘭定義為台灣"東部", 但這個專案裡宜蘭是定義在 "北部", 應該要出現在 "桃園縣" 的上方.


原本的javascript 程式碼如下:
function initialCityOptionTW(){
    cityarea_account[0] = 0;
    cityarea[1] = '仁愛區';
    cityarea[2] = '信義區';
    cityarea[3] = '中正區';
    cityarea[4] = '中山區';
    cityarea[5] = '安樂區';
    cityarea[6] = '暖暖區';
    cityarea[7] = '七堵區';
    cityarea_account[1] = 7;
    cityarea[8] = '中正區';
    cityarea[9] = '大同區';
    cityarea[10] = '中山區';
    cityarea[11] = '松山區';
    cityarea[12] = '大安區';
    cityarea[13] = '萬華區';
    cityarea[14] = '信義區';
    cityarea[15] = '士林區';
    cityarea[16] = '北投區';
    cityarea[17] = '內湖區';
    cityarea[18] = '南港區';
    cityarea[19] = '文山區';
    cityarea_account[2] = 19;
    cityarea[20] = '萬里區';
    cityarea[21] = '金山區';
    cityarea[22] = '板橋區';
    cityarea[23] = '汐止區';
    cityarea[24] = '深坑區';
    cityarea[25] = '石碇區';
    cityarea[26] = '瑞芳區';
    cityarea[27] = '平溪區';
    cityarea[28] = '雙溪區';
    cityarea[29] = '貢寮區';
    cityarea[30] = '新店區';
    cityarea[31] = '坪林區';
    cityarea[32] = '烏來區';
    cityarea[33] = '永和區';
    cityarea[34] = '中和區';
    cityarea[35] = '土城區';
    cityarea[36] = '三峽區';
    cityarea[37] = '樹林區';
    cityarea[38] = '鶯歌區';
    cityarea[39] = '三重區';
    cityarea[40] = '新莊區';
    cityarea[41] = '泰山區';
    cityarea[42] = '林口區';
    cityarea[43] = '蘆洲區';
    cityarea[44] = '五股區';
    cityarea[45] = '八里區';
    cityarea[46] = '淡水區';
    cityarea[47] = '三芝區';
    cityarea[48] = '石門區';
    cityarea_account[3] = 48;
    cityarea[49] = '中壢市';
    cityarea[50] = '平鎮市';
    cityarea[51] = '龍潭鄉';
    cityarea[52] = '楊梅市';
    cityarea[53] = '新屋鄉';
    cityarea[54] = '觀音鄉';
    cityarea[55] = '桃園市';
    cityarea[56] = '龜山鄉';
    cityarea[57] = '八德市';
    cityarea[58] = '大溪鎮';
    cityarea[59] = '復興鄉';
    cityarea[60] = '大園鄉';
    cityarea[61] = '蘆竹鄉';
    cityarea_account[4] = 61;
    cityarea[62] = '東區';
    cityarea[63] = '北區';
    cityarea[64] = '香山區';
    cityarea_account[5] = 64;
    cityarea[65] = '竹北市';
    cityarea[66] = '湖口鄉';
    cityarea[67] = '新豐鄉';
    cityarea[68] = '新埔鎮';
    cityarea[69] = '關西鎮';
    cityarea[70] = '芎林鄉';
    cityarea[71] = '寶山鄉';
    cityarea[72] = '竹東鎮';
    cityarea[73] = '五峰鄉';
    cityarea[74] = '橫山鄉';
    cityarea[75] = '尖石鄉';
    cityarea[76] = '北埔鄉';
    cityarea[77] = '峨眉鄉';
    cityarea_account[6] = 77;
    cityarea[78] = '竹南鎮';
    cityarea[79] = '頭份鎮';
    cityarea[80] = '三灣鄉';
    cityarea[81] = '南庄鄉';
    cityarea[82] = '獅潭鄉';
    cityarea[83] = '後龍鎮';
    cityarea[84] = '通霄鎮';
    cityarea[85] = '苑裡鎮';
    cityarea[86] = '苗栗市';
    cityarea[87] = '造橋鄉';
    cityarea[88] = '頭屋鄉';
    cityarea[89] = '公館鄉';
    cityarea[90] = '大湖鄉';
    cityarea[91] = '泰安鄉';
    cityarea[92] = '銅鑼鄉';
    cityarea[93] = '三義鄉';
    cityarea[94] = '西湖鄉';
    cityarea[95] = '卓蘭鎮';
    cityarea_account[7] = 95;
    cityarea[96] = '中區';
    cityarea[97] = '東區';
    cityarea[98] = '南區';
    cityarea[99] = '西區';
    cityarea[100] = '北區';
    cityarea[101] = '北屯區';
    cityarea[102] = '西屯區';
    cityarea[103] = '南屯區';
    cityarea[104] = '太平區';
    cityarea[105] = '大里區';
    cityarea[106] = '霧峰區';
    cityarea[107] = '烏日區';
    cityarea[108] = '豐原區';
    cityarea[109] = '后里區';
    cityarea[110] = '石岡區';
    cityarea[111] = '東勢區';
    cityarea[112] = '和平區';
    cityarea[113] = '新社區';
    cityarea[114] = '潭子區';
    cityarea[115] = '大雅區';
    cityarea[116] = '神岡區';
    cityarea[117] = '大肚區';
    cityarea[118] = '沙鹿區';
    cityarea[119] = '龍井區';
    cityarea[120] = '梧棲區';
    cityarea[121] = '清水區';
    cityarea[122] = '大甲區';
    cityarea[123] = '外埔區';
    cityarea[124] = '大安區';
    cityarea_account[8] = 124;
    cityarea[125] = '彰化市';
    cityarea[126] = '芬園鄉';
    cityarea[127] = '花壇鄉';
    cityarea[128] = '秀水鄉';
    cityarea[129] = '鹿港鎮';
    cityarea[130] = '福興鄉';
    cityarea[131] = '線西鄉';
    cityarea[132] = '和美鎮';
    cityarea[133] = '伸港鄉';
    cityarea[134] = '員林鎮';
    cityarea[135] = '社頭鄉';
    cityarea[136] = '永靖鄉';
    cityarea[137] = '埔心鄉';
    cityarea[138] = '溪湖鎮';
    cityarea[139] = '大村鄉';
    cityarea[140] = '埔鹽鄉';
    cityarea[141] = '田中鎮';
    cityarea[142] = '北斗鎮';
    cityarea[143] = '田尾鄉';
    cityarea[144] = '埤頭鄉';
    cityarea[145] = '溪州鄉';
    cityarea[146] = '竹塘鄉';
    cityarea[147] = '二林鎮';
    cityarea[148] = '大城鄉';
    cityarea[149] = '芳苑鄉';
    cityarea[150] = '二水鄉';
    cityarea_account[9] = 150;
    cityarea[151] = '南投市';
    cityarea[152] = '中寮鄉';
    cityarea[153] = '草屯鎮';
    cityarea[154] = '國姓鄉';
    cityarea[155] = '埔里鎮';
    cityarea[156] = '仁愛鄉';
    cityarea[157] = '名間鄉';
    cityarea[158] = '集集鎮';
    cityarea[159] = '水里鄉';
    cityarea[160] = '魚池鄉';
    cityarea[161] = '信義鄉';
    cityarea[162] = '竹山鎮';
    cityarea[163] = '鹿谷鄉';
    cityarea_account[10] = 163;
    cityarea[164] = '斗南鎮';
    cityarea[165] = '大埤鄉';
    cityarea[166] = '虎尾鎮';
    cityarea[167] = '土庫鎮';
    cityarea[168] = '褒忠鄉';
    cityarea[169] = '東勢鄉';
    cityarea[170] = '台西鄉';
    cityarea[171] = '崙背鄉';
    cityarea[172] = '麥寮鄉';
    cityarea[173] = '斗六市';
    cityarea[174] = '林內鄉';
    cityarea[175] = '古坑鄉';
    cityarea[176] = '莿桐鄉';
    cityarea[177] = '西螺鎮';
    cityarea[178] = '二崙鄉';
    cityarea[179] = '北港鎮';
    cityarea[180] = '水林鄉';
    cityarea[181] = '口湖鄉';
    cityarea[182] = '四湖鄉';
    cityarea[183] = '元長鄉';
    cityarea_account[11] = 183;
    cityarea[184] = '東區';
    cityarea[185] = '西區';
    cityarea_account[12] = 185;
    cityarea[186] = '番路鄉';
    cityarea[187] = '梅山鄉';
    cityarea[188] = '竹崎鄉';
    cityarea[189] = '阿里山鄉';
    cityarea[190] = '中埔鄉';
    cityarea[191] = '大埔鄉';
    cityarea[192] = '水上鄉';
    cityarea[193] = '鹿草鄉';
    cityarea[194] = '太保市';
    cityarea[195] = '朴子市';
    cityarea[196] = '東石鄉';
    cityarea[197] = '六腳鄉';
    cityarea[198] = '新港鄉';
    cityarea[199] = '民雄鄉';
    cityarea[200] = '大林鎮';
    cityarea[201] = '溪口鄉';
    cityarea[202] = '義竹鄉';
    cityarea[203] = '布袋鎮';
    cityarea_account[13] = 203;
    cityarea[204] = '中西區';
    cityarea[205] = '東區';
    cityarea[206] = '南區';
    cityarea[207] = '北區';
    cityarea[208] = '安平區';
    cityarea[209] = '安南區';
    cityarea[210] = '永康區';
    cityarea[211] = '歸仁區';
    cityarea[212] = '新化區';
    cityarea[213] = '左鎮區';
    cityarea[214] = '玉井區';
    cityarea[215] = '楠西區';
    cityarea[216] = '南化區';
    cityarea[217] = '仁德區';
    cityarea[218] = '關廟區';
    cityarea[219] = '龍崎區';
    cityarea[220] = '官田區';
    cityarea[221] = '麻豆區';
    cityarea[222] = '佳里區';
    cityarea[223] = '西港區';
    cityarea[224] = '七股區';
    cityarea[225] = '將軍區';
    cityarea[226] = '學甲區';
    cityarea[227] = '北門區';
    cityarea[228] = '新營區';
    cityarea[229] = '後壁區';
    cityarea[230] = '白河區';
    cityarea[231] = '東山區';
    cityarea[232] = '六甲區';
    cityarea[233] = '下營區';
    cityarea[234] = '柳營區';
    cityarea[235] = '鹽水區';
    cityarea[236] = '善化區';
    cityarea[237] = '大內區';
    cityarea[238] = '山上區';
    cityarea[239] = '新市區';
    cityarea[240] = '安定區';
    cityarea_account[14] = 240;
    cityarea[241] = '新興區';
    cityarea[242] = '前金區';
    cityarea[243] = '苓雅區';
    cityarea[244] = '鹽埕區';
    cityarea[245] = '鼓山區';
    cityarea[246] = '旗津區';
    cityarea[247] = '前鎮區';
    cityarea[248] = '三民區';
    cityarea[249] = '楠梓區';
    cityarea[250] = '小港區';
    cityarea[251] = '左營區';
    cityarea[252] = '仁武區';
    cityarea[253] = '大社區';
    cityarea[254] = '東沙群島';
    cityarea[255] = '南沙群島';
    cityarea[256] = '岡山區';
    cityarea[257] = '路竹區';
    cityarea[258] = '阿蓮區';
    cityarea[259] = '田寮區';
    cityarea[260] = '燕巢區';
    cityarea[261] = '橋頭區';
    cityarea[262] = '梓官區';
    cityarea[263] = '彌陀區';
    cityarea[264] = '永安區';
    cityarea[265] = '湖內區';
    cityarea[266] = '鳳山區';
    cityarea[267] = '大寮區';
    cityarea[268] = '林園區';
    cityarea[269] = '鳥松區';
    cityarea[270] = '大樹區';
    cityarea[271] = '旗山區';
    cityarea[272] = '美濃區';
    cityarea[273] = '六龜區';
    cityarea[274] = '內門區';
    cityarea[275] = '杉林區';
    cityarea[276] = '甲仙區';
    cityarea[277] = '桃源區';
    cityarea[278] = '那瑪夏區';
    cityarea[279] = '茂林區';
    cityarea[280] = '茄萣區';
    cityarea_account[15] = 280;
    cityarea[281] = '屏東市';
    cityarea[282] = '三地門鄉';
    cityarea[283] = '霧台鄉';
    cityarea[284] = '瑪家鄉';
    cityarea[285] = '九如鄉';
    cityarea[286] = '里港鄉';
    cityarea[287] = '高樹鄉';
    cityarea[288] = '鹽埔鄉';
    cityarea[289] = '長治鄉';
    cityarea[290] = '麟洛鄉';
    cityarea[291] = '竹田鄉';
    cityarea[292] = '內埔鄉';
    cityarea[293] = '萬丹鄉';
    cityarea[294] = '潮州鎮';
    cityarea[295] = '泰武鄉';
    cityarea[296] = '來義鄉';
    cityarea[297] = '萬巒鄉';
    cityarea[298] = '崁頂鄉';
    cityarea[299] = '新埤鄉';
    cityarea[300] = '南州鄉';
    cityarea[301] = '林邊鄉';
    cityarea[302] = '東港鎮';
    cityarea[303] = '琉球鄉';
    cityarea[304] = '佳冬鄉';
    cityarea[305] = '新園鄉';
    cityarea[306] = '枋寮鄉';
    cityarea[307] = '枋山鄉';
    cityarea[308] = '春日鄉';
    cityarea[309] = '獅子鄉';
    cityarea[310] = '車城鄉';
    cityarea[311] = '牡丹鄉';
    cityarea[312] = '恆春鎮';
    cityarea[313] = '滿州鄉';
    cityarea_account[16] = 313;
    cityarea[314] = '台東市';
    cityarea[315] = '綠島鄉';
    cityarea[316] = '蘭嶼鄉';
    cityarea[317] = '延平鄉';
    cityarea[318] = '卑南鄉';
    cityarea[319] = '鹿野鄉';
    cityarea[320] = '關山鎮';
    cityarea[321] = '海端鄉';
    cityarea[322] = '池上鄉';
    cityarea[323] = '東河鄉';
    cityarea[324] = '成功鎮';
    cityarea[325] = '長濱鄉';
    cityarea[326] = '太麻里鄉';
    cityarea[327] = '金峰鄉';
    cityarea[328] = '大武鄉';
    cityarea[329] = '達仁鄉';
    cityarea_account[17] = 329;
    cityarea[330] = '花蓮市';
    cityarea[331] = '新城鄉';
    cityarea[332] = '秀林鄉';
    cityarea[333] = '吉安鄉';
    cityarea[334] = '壽豐鄉';
    cityarea[335] = '鳳林鎮';
    cityarea[336] = '光復鄉';
    cityarea[337] = '豐濱鄉';
    cityarea[338] = '瑞穗鄉';
    cityarea[339] = '萬榮鄉';
    cityarea[340] = '玉里鎮';
    cityarea[341] = '卓溪鄉';
    cityarea[342] = '富里鄉';
    cityarea_account[18] = 342;
    cityarea[343] = '宜蘭市';
    cityarea[344] = '頭城鎮';
    cityarea[345] = '礁溪鄉';
    cityarea[346] = '壯圍鄉';
    cityarea[347] = '員山鄉';
    cityarea[348] = '羅東鎮';
    cityarea[349] = '三星鄉';
    cityarea[350] = '大同鄉';
    cityarea[351] = '五結鄉';
    cityarea[352] = '冬山鄉';
    cityarea[353] = '蘇澳鎮';
    cityarea[354] = '南澳鄉';
    cityarea[355] = '釣魚台';
    cityarea_account[19] = 355;
    cityarea[356] = '馬公市';
    cityarea[357] = '西嶼鄉';
    cityarea[358] = '望安鄉';
    cityarea[359] = '七美鄉';
    cityarea[360] = '白沙鄉';
    cityarea[361] = '湖西鄉';
    cityarea_account[20] = 361;
    cityarea[362] = '金沙鎮';
    cityarea[363] = '金湖鎮';
    cityarea[364] = '金寧鄉';
    cityarea[365] = '金城鎮';
    cityarea[366] = '烈嶼鄉';
    cityarea[367] = '烏坵鄉';
    cityarea_account[21] = 367;
    cityarea[368] = '南竿鄉';
    cityarea[369] = '北竿鄉';
    cityarea[370] = '莒光鄉';
    cityarea[371] = '東引鄉';
    cityarea_account[22] = 371;
    cityarea[372] = '東沙群島';
    cityarea[373] = '南沙群島';
    cityarea_account[23] = 373;
    cityarea[374] = '釣魚台';
    city_account = 23;
}

說明: 如果要移動宜蘭的位置, 要修改掉的行數多到... 我都累了,


我的解法,

step 1: 透過 Notepad++ 的 RegExp 取代,
目前的資料為:
cityarea[374] = '釣魚台';
你希望要變成:
cityarea.push('釣魚台');

請使用 [SearchPattern]:
cityarea\[([0-9]+)\] = '(.+)'
並輸入 [ReplacePattern]:
cityarea.push\('\2'\)

替換,陣列絕對坐標為相對坐標後的程式碼:
function initialCityOptionTW(){
    cityarea_account.push(0);
    cityarea.push('');
    cityarea.push('仁愛區');
    cityarea.push('信義區');
    cityarea.push('中正區');
    cityarea.push('中山區');
    cityarea.push('安樂區');
    cityarea.push('暖暖區');
    cityarea.push('七堵區');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('中正區');
    cityarea.push('大同區');
    cityarea.push('中山區');
    cityarea.push('松山區');
    cityarea.push('大安區');
    cityarea.push('萬華區');
    cityarea.push('信義區');
    cityarea.push('士林區');
    cityarea.push('北投區');
    cityarea.push('內湖區');
    cityarea.push('南港區');
    cityarea.push('文山區');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('萬里區');
    cityarea.push('金山區');
    cityarea.push('板橋區');
    cityarea.push('汐止區');
    cityarea.push('深坑區');
    cityarea.push('石碇區');
    cityarea.push('瑞芳區');
    cityarea.push('平溪區');
    cityarea.push('雙溪區');
    cityarea.push('貢寮區');
    cityarea.push('新店區');
    cityarea.push('坪林區');
    cityarea.push('烏來區');
    cityarea.push('永和區');
    cityarea.push('中和區');
    cityarea.push('土城區');
    cityarea.push('三峽區');
    cityarea.push('樹林區');
    cityarea.push('鶯歌區');
    cityarea.push('三重區');
    cityarea.push('新莊區');
    cityarea.push('泰山區');
    cityarea.push('林口區');
    cityarea.push('蘆洲區');
    cityarea.push('五股區');
    cityarea.push('八里區');
    cityarea.push('淡水區');
    cityarea.push('三芝區');
    cityarea.push('石門區');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('中壢市');
    cityarea.push('平鎮市');
    cityarea.push('龍潭鄉');
    cityarea.push('楊梅市');
    cityarea.push('新屋鄉');
    cityarea.push('觀音鄉');
    cityarea.push('桃園市');
    cityarea.push('龜山鄉');
    cityarea.push('八德市');
    cityarea.push('大溪鎮');
    cityarea.push('復興鄉');
    cityarea.push('大園鄉');
    cityarea.push('蘆竹鄉');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('東區');
    cityarea.push('北區');
    cityarea.push('香山區');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('竹北市');
    cityarea.push('湖口鄉');
    cityarea.push('新豐鄉');
    cityarea.push('新埔鎮');
    cityarea.push('關西鎮');
    cityarea.push('芎林鄉');
    cityarea.push('寶山鄉');
    cityarea.push('竹東鎮');
    cityarea.push('五峰鄉');
    cityarea.push('橫山鄉');
    cityarea.push('尖石鄉');
    cityarea.push('北埔鄉');
    cityarea.push('峨眉鄉');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('竹南鎮');
    cityarea.push('頭份鎮');
    cityarea.push('三灣鄉');
    cityarea.push('南庄鄉');
    cityarea.push('獅潭鄉');
    cityarea.push('後龍鎮');
    cityarea.push('通霄鎮');
    cityarea.push('苑裡鎮');
    cityarea.push('苗栗市');
    cityarea.push('造橋鄉');
    cityarea.push('頭屋鄉');
    cityarea.push('公館鄉');
    cityarea.push('大湖鄉');
    cityarea.push('泰安鄉');
    cityarea.push('銅鑼鄉');
    cityarea.push('三義鄉');
    cityarea.push('西湖鄉');
    cityarea.push('卓蘭鎮');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('中區');
    cityarea.push('東區');
    cityarea.push('南區');
    cityarea.push('西區');
    cityarea.push('北區');
    cityarea.push('北屯區');
    cityarea.push('西屯區');
    cityarea.push('南屯區');
    cityarea.push('太平區');
    cityarea.push('大里區');
    cityarea.push('霧峰區');
    cityarea.push('烏日區');
    cityarea.push('豐原區');
    cityarea.push('后里區');
    cityarea.push('石岡區');
    cityarea.push('東勢區');
    cityarea.push('和平區');
    cityarea.push('新社區');
    cityarea.push('潭子區');
    cityarea.push('大雅區');
    cityarea.push('神岡區');
    cityarea.push('大肚區');
    cityarea.push('沙鹿區');
    cityarea.push('龍井區');
    cityarea.push('梧棲區');
    cityarea.push('清水區');
    cityarea.push('大甲區');
    cityarea.push('外埔區');
    cityarea.push('大安區');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('彰化市');
    cityarea.push('芬園鄉');
    cityarea.push('花壇鄉');
    cityarea.push('秀水鄉');
    cityarea.push('鹿港鎮');
    cityarea.push('福興鄉');
    cityarea.push('線西鄉');
    cityarea.push('和美鎮');
    cityarea.push('伸港鄉');
    cityarea.push('員林鎮');
    cityarea.push('社頭鄉');
    cityarea.push('永靖鄉');
    cityarea.push('埔心鄉');
    cityarea.push('溪湖鎮');
    cityarea.push('大村鄉');
    cityarea.push('埔鹽鄉');
    cityarea.push('田中鎮');
    cityarea.push('北斗鎮');
    cityarea.push('田尾鄉');
    cityarea.push('埤頭鄉');
    cityarea.push('溪州鄉');
    cityarea.push('竹塘鄉');
    cityarea.push('二林鎮');
    cityarea.push('大城鄉');
    cityarea.push('芳苑鄉');
    cityarea.push('二水鄉');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('南投市');
    cityarea.push('中寮鄉');
    cityarea.push('草屯鎮');
    cityarea.push('國姓鄉');
    cityarea.push('埔里鎮');
    cityarea.push('仁愛鄉');
    cityarea.push('名間鄉');
    cityarea.push('集集鎮');
    cityarea.push('水里鄉');
    cityarea.push('魚池鄉');
    cityarea.push('信義鄉');
    cityarea.push('竹山鎮');
    cityarea.push('鹿谷鄉');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('斗南鎮');
    cityarea.push('大埤鄉');
    cityarea.push('虎尾鎮');
    cityarea.push('土庫鎮');
    cityarea.push('褒忠鄉');
    cityarea.push('東勢鄉');
    cityarea.push('台西鄉');
    cityarea.push('崙背鄉');
    cityarea.push('麥寮鄉');
    cityarea.push('斗六市');
    cityarea.push('林內鄉');
    cityarea.push('古坑鄉');
    cityarea.push('莿桐鄉');
    cityarea.push('西螺鎮');
    cityarea.push('二崙鄉');
    cityarea.push('北港鎮');
    cityarea.push('水林鄉');
    cityarea.push('口湖鄉');
    cityarea.push('四湖鄉');
    cityarea.push('元長鄉');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('東區');
    cityarea.push('西區');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('番路鄉');
    cityarea.push('梅山鄉');
    cityarea.push('竹崎鄉');
    cityarea.push('阿里山鄉');
    cityarea.push('中埔鄉');
    cityarea.push('大埔鄉');
    cityarea.push('水上鄉');
    cityarea.push('鹿草鄉');
    cityarea.push('太保市');
    cityarea.push('朴子市');
    cityarea.push('東石鄉');
    cityarea.push('六腳鄉');
    cityarea.push('新港鄉');
    cityarea.push('民雄鄉');
    cityarea.push('大林鎮');
    cityarea.push('溪口鄉');
    cityarea.push('義竹鄉');
    cityarea.push('布袋鎮');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('中西區');
    cityarea.push('東區');
    cityarea.push('南區');
    cityarea.push('北區');
    cityarea.push('安平區');
    cityarea.push('安南區');
    cityarea.push('永康區');
    cityarea.push('歸仁區');
    cityarea.push('新化區');
    cityarea.push('左鎮區');
    cityarea.push('玉井區');
    cityarea.push('楠西區');
    cityarea.push('南化區');
    cityarea.push('仁德區');
    cityarea.push('關廟區');
    cityarea.push('龍崎區');
    cityarea.push('官田區');
    cityarea.push('麻豆區');
    cityarea.push('佳里區');
    cityarea.push('西港區');
    cityarea.push('七股區');
    cityarea.push('將軍區');
    cityarea.push('學甲區');
    cityarea.push('北門區');
    cityarea.push('新營區');
    cityarea.push('後壁區');
    cityarea.push('白河區');
    cityarea.push('東山區');
    cityarea.push('六甲區');
    cityarea.push('下營區');
    cityarea.push('柳營區');
    cityarea.push('鹽水區');
    cityarea.push('善化區');
    cityarea.push('大內區');
    cityarea.push('山上區');
    cityarea.push('新市區');
    cityarea.push('安定區');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('新興區');
    cityarea.push('前金區');
    cityarea.push('苓雅區');
    cityarea.push('鹽埕區');
    cityarea.push('鼓山區');
    cityarea.push('旗津區');
    cityarea.push('前鎮區');
    cityarea.push('三民區');
    cityarea.push('楠梓區');
    cityarea.push('小港區');
    cityarea.push('左營區');
    cityarea.push('仁武區');
    cityarea.push('大社區');
    cityarea.push('東沙群島');
    cityarea.push('南沙群島');
    cityarea.push('岡山區');
    cityarea.push('路竹區');
    cityarea.push('阿蓮區');
    cityarea.push('田寮區');
    cityarea.push('燕巢區');
    cityarea.push('橋頭區');
    cityarea.push('梓官區');
    cityarea.push('彌陀區');
    cityarea.push('永安區');
    cityarea.push('湖內區');
    cityarea.push('鳳山區');
    cityarea.push('大寮區');
    cityarea.push('林園區');
    cityarea.push('鳥松區');
    cityarea.push('大樹區');
    cityarea.push('旗山區');
    cityarea.push('美濃區');
    cityarea.push('六龜區');
    cityarea.push('內門區');
    cityarea.push('杉林區');
    cityarea.push('甲仙區');
    cityarea.push('桃源區');
    cityarea.push('那瑪夏區');
    cityarea.push('茂林區');
    cityarea.push('茄萣區');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('屏東市');
    cityarea.push('三地門鄉');
    cityarea.push('霧台鄉');
    cityarea.push('瑪家鄉');
    cityarea.push('九如鄉');
    cityarea.push('里港鄉');
    cityarea.push('高樹鄉');
    cityarea.push('鹽埔鄉');
    cityarea.push('長治鄉');
    cityarea.push('麟洛鄉');
    cityarea.push('竹田鄉');
    cityarea.push('內埔鄉');
    cityarea.push('萬丹鄉');
    cityarea.push('潮州鎮');
    cityarea.push('泰武鄉');
    cityarea.push('來義鄉');
    cityarea.push('萬巒鄉');
    cityarea.push('崁頂鄉');
    cityarea.push('新埤鄉');
    cityarea.push('南州鄉');
    cityarea.push('林邊鄉');
    cityarea.push('東港鎮');
    cityarea.push('琉球鄉');
    cityarea.push('佳冬鄉');
    cityarea.push('新園鄉');
    cityarea.push('枋寮鄉');
    cityarea.push('枋山鄉');
    cityarea.push('春日鄉');
    cityarea.push('獅子鄉');
    cityarea.push('車城鄉');
    cityarea.push('牡丹鄉');
    cityarea.push('恆春鎮');
    cityarea.push('滿州鄉');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('台東市');
    cityarea.push('綠島鄉');
    cityarea.push('蘭嶼鄉');
    cityarea.push('延平鄉');
    cityarea.push('卑南鄉');
    cityarea.push('鹿野鄉');
    cityarea.push('關山鎮');
    cityarea.push('海端鄉');
    cityarea.push('池上鄉');
    cityarea.push('東河鄉');
    cityarea.push('成功鎮');
    cityarea.push('長濱鄉');
    cityarea.push('太麻里鄉');
    cityarea.push('金峰鄉');
    cityarea.push('大武鄉');
    cityarea.push('達仁鄉');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('花蓮市');
    cityarea.push('新城鄉');
    cityarea.push('秀林鄉');
    cityarea.push('吉安鄉');
    cityarea.push('壽豐鄉');
    cityarea.push('鳳林鎮');
    cityarea.push('光復鄉');
    cityarea.push('豐濱鄉');
    cityarea.push('瑞穗鄉');
    cityarea.push('萬榮鄉');
    cityarea.push('玉里鎮');
    cityarea.push('卓溪鄉');
    cityarea.push('富里鄉');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('宜蘭市');
    cityarea.push('頭城鎮');
    cityarea.push('礁溪鄉');
    cityarea.push('壯圍鄉');
    cityarea.push('員山鄉');
    cityarea.push('羅東鎮');
    cityarea.push('三星鄉');
    cityarea.push('大同鄉');
    cityarea.push('五結鄉');
    cityarea.push('冬山鄉');
    cityarea.push('蘇澳鎮');
    cityarea.push('南澳鄉');
    cityarea.push('釣魚台');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('馬公市');
    cityarea.push('西嶼鄉');
    cityarea.push('望安鄉');
    cityarea.push('七美鄉');
    cityarea.push('白沙鄉');
    cityarea.push('湖西鄉');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('金沙鎮');
    cityarea.push('金湖鎮');
    cityarea.push('金寧鄉');
    cityarea.push('金城鎮');
    cityarea.push('烈嶼鄉');
    cityarea.push('烏坵鄉');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('南竿鄉');
    cityarea.push('北竿鄉');
    cityarea.push('莒光鄉');
    cityarea.push('東引鄉');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('東沙群島');
    cityarea.push('南沙群島');
    cityarea_account.push(cityarea.length-2);
    cityarea.push('釣魚台');
}

這個時候, 要怎麼移動聯動裡Option 的值就很方便, 整個區塊移走就ok了.



相關文章:



沒有留言:

張貼留言

Facebook 留言板