C++:计算vector的和

问题

很简单的一个问题.
如下:

  1. 编写程序处理一个vector,其元素都表示整形值,计算vector中所有元素的和.
  2. 修改程序,使之计算表示浮点值的string之和.

C++.
image-2079

源代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*************************************************************************
    > File Name: test.9.50.cpp
    > Author: puruidong
    > Mail: 1@w1520.com
    > Created Time: 2014年05月29日
 ************************************************************************/

#include<iostream>
#include<vector>
#include<iterator>
#include<string>
using namespace std;

/*******************************
 
编写程序处理一个vector<string>,其元素都表示整形值,计算vector中所有元素的和.修改程序,使之计算表示浮点值的string之和.

 ***********************************/
 int main()
 {
     vector<string> vec;
     vec.push_back("100.5");
     vec.push_back("50.5");
     vec.push_back("20.5");
     vec.push_back("10.2");
    double count(0);
     for(vector<string>::iterator it=vec.begin();it!=vec.end();++it)
     {
        count+=stod(*it);
     }
    cout << count << endl;
    //下面是第二个问题.
    vector<double> vedou;
    vedou.push_back(10.5);
    vedou.push_back(15.7);
    vedou.push_back(12.3);
    vedou.push_back(20.5);
    double countds(0);
     string countcds ;
    for(vector<double>::iterator itdou=vedou.begin();itdou!=vedou.end();++itdou)
     {
         countds+=(*itdou);
         //countcds=to_string(countds);
     }
     cout << "下面是计算表示浮点值的string之和:" << endl;
         countcds=to_string(countds);
    cout << countcds << endl;
    return 0;
 }

C++:vector初始化string

两个问题

  1. 编写程序,从一个vector初始化一个string.
  2. 假定你希望每次读取一个字符存入一个string中,而且知道最少需要读取100个字符,应该如何提高程序的性能.

C++.
image-2077

源码1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*************************************************************************
    > File Name: test.9.41.cpp
    > Author: puruidong
    > Mail: 1@w1520.com
    > Created Time: 2014年05月25日 星期日
 ************************************************************************/

#include<iostream>
#include<vector>
#include<iterator>
using namespace std;

int main()
{
    vector<char> vec;
    vec.push_back('h');
    vec.push_back('e');
    vec.push_back('l');
    vec.push_back('l');
    vec.push_back('o');    
    string s(vec.begin(),vec.end());
    cout << s << endl;
    return 0;
}

源码2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*************************************************************************
    > File Name: test.9.42.cpp
    > Author: puruidong
    > Mail: 1@w1520.com
    > Created Time: 2014年05月25日 星期日
 ************************************************************************/
#include<vector>
#include<iostream>

using namespace std;

int main()
{
    char s;
    vector<char> vec;
    cout << "输入单个字母:" << endl;
    while(cin >> s)
    {
        vec.push_back(s);
    }
    string sa(vec.begin(),vec.end());
    cout << sa << endl;
    return 0;
}

jQuery:选择省输出相应市

说明下

部分资料来自网络,有修改.[原文]
只有全国市,具体效果如下:

html效果图
image-2066

源码

在chrome下测试通过.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!doctype html>
<head>
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
/*
  city.js
  BusinessOn

  Created by 吴小海 on 12-4-5.
  Copyright 2012年 蓝运方小. All rights reserved.
*/
var cityArray = new Array(); //定义城市数组
cityArray[0] = new Array("北京");
cityArray[1] = new Array("上海");
cityArray[2] = new Array("天津");
cityArray[3] = new Array("重庆");
cityArray[4] = new Array("石家庄,邯郸,邢台,保定,张家口,承德,廊坊,唐山,秦皇岛,沧州,衡水");
cityArray[5] = new Array("太原,大同,阳泉,长治,晋城,朔州,吕梁,忻州,晋中,临汾,运城");
cityArray[6] = new Array("呼和浩特,包头,乌海,赤峰,呼伦贝尔盟,阿拉善盟,哲里木盟,兴安盟,乌兰察布盟,锡林郭勒盟,巴彦淖尔盟,伊克昭盟");
cityArray[7] = new Array("沈阳,大连,鞍山,抚顺,本溪,丹东,锦州,营口,阜新,辽阳,盘锦,铁岭,朝阳,葫芦岛");
cityArray[8] = new Array("长春,吉林,四平,辽源,通化,白山,松原,白城,延边");
cityArray[9] = new Array("哈尔滨,齐齐哈尔,牡丹江,佳木斯,大庆,绥化,鹤岗,鸡西,黑河,双鸭山,伊春,七台河,大兴安岭");
cityArray[10] = new Array("南京,镇江,苏州,南通,扬州,盐城,徐州,连云港,常州,无锡,宿迁,泰州,淮安");
cityArray[11] = new Array("杭州,宁波,温州,嘉兴,湖州,绍兴,金华,衢州,舟山,台州,丽水");
cityArray[12] = new Array("合肥,芜湖,蚌埠,马鞍山,淮北,铜陵,安庆,黄山,滁州,宿州,池州,淮南,巢湖,阜阳,六安,宣城,亳州");
cityArray[13] = new Array("福州,厦门,莆田,三明,泉州,漳州,南平,龙岩,宁德");
cityArray[14] = new Array("南昌,景德镇,九江,鹰潭,萍乡,新馀,赣州,吉安,宜春,抚州,上饶");
cityArray[15] = new Array("济南,青岛,淄博,枣庄,东营,烟台,潍坊,济宁,泰安,威海,日照,莱芜,临沂,德州,聊城,滨州,菏泽");
cityArray[16] = new Array("郑州,开封,洛阳,平顶山,安阳,鹤壁,新乡,焦作,濮阳,许昌,漯河,三门峡,南阳,商丘,信阳,周口,驻马店,济源");
cityArray[17] = new Array("武汉,宜昌,荆州,襄樊,黄石,荆门,黄冈,十堰,恩施,潜江,天门,仙桃,随州,咸宁,孝感,鄂州");
cityArray[18] = new Array("长沙,常德,株洲,湘潭,衡阳,岳阳,邵阳,益阳,娄底,怀化,郴州,永州,湘西,张家界");
cityArray[19] = new Array("广州,深圳,珠海,汕头,东莞,中山,佛山,韶关,江门,湛江,茂名,肇庆,惠州,梅州,汕尾,河源,阳江,清远,潮州,揭阳,云浮");
cityArray[20] = new Array("南宁,柳州,桂林,梧州,北海,防城港,钦州,贵港,玉林,南宁地区,柳州地区,贺州,百色,河池");
cityArray[21] = new Array("海口,三亚");
cityArray[22] = new Array("成都,绵阳,德阳,自贡,攀枝花,广元,内江,乐山,南充,宜宾,广安,达川,雅安,眉山,甘孜,凉山,泸州");
cityArray[23] = new Array("贵阳,六盘水,遵义,安顺,铜仁,黔西南,毕节,黔东南,黔南");
cityArray[24] = new Array("昆明,大理,曲靖,玉溪,昭通,楚雄,红河,文山,思茅,西双版纳,保山,德宏,丽江,怒江,迪庆,临沧");
cityArray[25] = new Array("拉萨,日喀则,山南,林芝,昌都,阿里,那曲");
cityArray[26] = new Array("西安,宝鸡,咸阳,铜川,渭南,延安,榆林,汉中,安康,商洛");
cityArray[27] = new Array("兰州,嘉峪关,金昌,白银,天水,酒泉,张掖,武威,定西,陇南,平凉,庆阳,临夏,甘南");
cityArray[28] = new Array("银川,石嘴山,吴忠,固原");
cityArray[29] = new Array("西宁,海东,海南,海北,黄南,玉树,果洛,海西");
cityArray[30] = new Array("乌鲁木齐,石河子,克拉玛依,伊犁,巴音郭勒,昌吉,克孜勒苏柯尔克孜,博尔塔拉,吐鲁番,哈密,喀什,和田,阿克苏");
cityArray[31] = new Array("香港");
cityArray[32] = new Array("澳门");
cityArray[33] = new Array("台湾");
</script>
</head>
<body>

            <div class="sheng">
                    <a href="javascript:void(0)" onClick="getCity(0,($(this).html()))">北京</a>
                    <a href="javascript:void(0)" onClick="getCity(1,($(this).html()))">上海</a>
                    <a href="javascript:void(0)" onClick="getCity(2,($(this).html()))">天津</a>
                    <a href="javascript:void(0)" onClick="getCity(3,($(this).html()))">重庆</a>
                    <a href="javascript:void(0)" onClick="getCity(4,($(this).html()))">河北</a>
                   <a href="javascript:void(0)" onClick="getCity(5,($(this).html()))"> 山西</a>
                    <a href="javascript:void(0)" onClick="getCity(6,($(this).html()))">内蒙古</a>
                    <a href="javascript:void(0)" onClick="getCity(7,($(this).html()))">辽宁</a>
                    <a href="javascript:void(0)" onClick="getCity(8,($(this).html()))">吉林</a><br /><br />
                    <a href="javascript:void(0)" onClick="getCity(9,($(this).html()))">黑龙江</a>
                    <a href="javascript:void(0)" onClick="getCity(10,($(this).html()))">江苏</a>
                    <a href="javascript:void(0)" onClick="getCity(11,($(this).html()))">浙江</a>
                    <a href="javascript:void(0)" onClick="getCity(12,($(this).html()))">安徽</a>
                    <a href="javascript:void(0)" onClick="getCity(13,($(this).html()))">福建</a>
                    <a href="javascript:void(0)" onClick="getCity(14,($(this).html()))">江西</a>
                    <a href="javascript:void(0)" onClick="getCity(15,($(this).html()))">山东</a>
                    <a href="javascript:void(0)" onClick="getCity(16,($(this).html()))">河南</a><br /><br />
                    <a href="javascript:void(0)" onClick="getCity(17,($(this).html()))">湖北</a>
                    <a href="javascript:void(0)" onClick="getCity(18,($(this).html()))">湖南</a>
                    <a href="javascript:void(0)" onClick="getCity(19,($(this).html()))">广东</a>
                    <a href="javascript:void(0)" onClick="getCity(20,($(this).html()))">广西</a>
                    <a href="javascript:void(0)" onClick="getCity(21,($(this).html()))">海南</a>
                    <a href="javascript:void(0)" onClick="getCity(22,($(this).html()))">四川</a><br /><br />
                    <a href="javascript:void(0)" onClick="getCity(23,($(this).html()))">贵州</a>
                    <a href="javascript:void(0)" onClick="getCity(24,($(this).html()))">云南</a>
                    <a href="javascript:void(0)" onClick="getCity(25,($(this).html()))">西藏</a>
                    <a href="javascript:void(0)" onClick="getCity(26,($(this).html()))">陕西</a>
                    <a href="javascript:void(0)" onClick="getCity(27,($(this).html()))">甘肃</a>
                    <a href="javascript:void(0)" onClick="getCity(28,($(this).html()))">宁夏</a>
                    <a href="javascript:void(0)" onClick="getCity(29,($(this).html()))">青海</a>
                    <a href="javascript:void(0)" onClick="getCity(30,($(this).html()))">新疆</a>
                    <a href="javascript:void(0)" onClick="getCity(31,($(this).html()))">香港</a>
                   <a href="javascript:void(0)" onClick="getCity(32,($(this).html()))">澳门</a>
                    <a href="javascript:void(0)" onClick="getCity(33,($(this).html()))">台湾</a>
            </div>
            <div class="shi">
           
            </div>
</body>

<script type="text/javascript">
                    function getCity(index,province)
                    {
                        var citys = ""+cityArray[index];
                        var cssk = new Array();
                         cssk=citys.split(",");
                         var html = '<h1>'+province+'</h1><ul>';
                         var hrefs="123456";
                        for(var i=0;i<cssk.length;i++)
                        {
                            html+='<li><a href="'+hrefs+'"&city="'+cssk[i]+'">'+cssk[i]+'</a></li><br />';
                        }
                        html+="</ul>";
                        $("div.shi").html(html);
                    }
</script>
</html>

C++:新概念!获取你想知道的!!

标题说明

标题党了.这次遇到的是capacity,可以获取vector和string不重新分配内存空间的话,当前容器可以保存多少元素.

不重新分配内存空间,当前容器可以保存多少元素,这个概念很重要。看图:

c++ capacity
image-2059

题目

解释下面的程序片段做了什么:

1
2
3
4
5
6
7
8
9
10
11
vector<string> svec;
svec.reserve(1024);//1
string word;
while(cin >> word)//2
{
    svec.push_back(word);
}
svec.resize(svec.size()+svec.size()/2);//3
//下面这句是新添加的,可以猜一下输出结果.
cout << "svec.size():" << svec.size() << endl;//4
cout << "svec.size():" << svec.capacity() << endl;//5

源码及解答

解答:

  • 在[1]这个地方为vector分配最少1024个空间
  • 在[2]添加元素,假如添加的元素个数是n[看下面,添加数量不一定.]个
  • 在[3]这个地方对容器的大小进行调整

可以猜一下在上面[4]和[5]要输出的值.【capacity的值完全依赖于实现,因此可能有所差异.及以下运行结果来自:gcc 4.8.2版本.】

源码1

添加数量为256个元素.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*************************************************************************
    > File Name: test.9.39.cpp
    > Author: puruidong
    > Mail: 1@w1520.com
    > Created Time: 2014年05月22日 星期四
 ************************************************************************/

#include<iostream>
#include<vector>
using namespace std;

int main()
{
    /*
   
    解释下面的程序片段做了什么?
    1.要求系统分配一个1024大小的空间;
    2.向vector中添加256个元素;
    3.缩小元素空间,vector中的实际元素是256个,由于除法是优先运算的,
    因此3的运算结果大致是256+256/2=384


    */
    vector<string> svec;
    svec.reserve(1024);//1
    //while(cin >> word)
    for(unsigned i=0;i!=256;++i)//2
    {
        svec.push_back(i+"test");
    }
    svec.resize(svec.size()+svec.size()/2);//3
    cout << "test>>" << svec.size() << endl;
    cout << "capacity>>" << svec.capacity() << endl;//此行输出依赖具体实现,我测试输出为1024.
    return 0;
}

c++ running
image-2060

源码2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*************************************************************************
    > File Name: test.9.39.cpp
    > Author: puruidong
    > Mail: 1@w1520.com
    > Created Time: 2014年05月22日 星期四
 ************************************************************************/

#include<iostream>
#include<vector>
using namespace std;

int main()
{
    /*
   
    解释下面的程序片段做了什么?
    1.要求系统分配一个1024大小的空间;
    2.向vector中添加512个元素;
    3.缩小元素空间,vector中的实际元素是512个,由于除法是优先运算的,
    因此3的运算结果大致是512+512/2=768.
    capacity的输出是1024[未超过预先设置的空间容量].

    */
    vector<string> svec;
    svec.reserve(1024);//1
    //while(cin >> word)
    for(unsigned i=0;i!=512;++i)//2
    {
        svec.push_back(i+"test");
    }
    svec.resize(svec.size()+svec.size()/2);//3(512+512/2)
    cout << "test>>" << svec.size() << endl;
    cout << "capacity>>" << svec.capacity() << endl;//输出结果依赖具体实现,此处输出1024.
    return 0;
}

C++.
image-2061

源码3

源码1和2有一个共同的特点,[3]的结算结果均未超过1024.下面的会有变化.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*************************************************************************
    > File Name: test.9.39.cpp
    > Author: puruidong
    > Mail: 1@w1520.com
    > Created Time: 2014年05月22日 星期四
 ************************************************************************/

#include<iostream>
#include<vector>
using namespace std;

int main()
{
    /*
   
    解释下面的程序片段做了什么?
    1.要求系统分配一个1024大小的空间;
    2.向vector中添加1000个元素;
    3.缩小元素空间,vector中的实际元素是1000个,由于除法是优先运算的,
    因此3的运算结果大致是(1000+500)=1500.
    4.容器长度未超出1024时,为1024.{超过则会新分配空间,具体依赖实现.}

    */
    vector<string> svec;
    svec.reserve(1024);//1
    //while(cin >> word)
    for(unsigned i=0;i!=1000;++i)//2
    {
        svec.push_back(i+"test");
    }
    svec.resize(svec.size()+svec.size()/2);//3
    cout << "test>>" << svec.size() << endl;
    cout << "capacity>>" << svec.capacity() << endl;//4,此处输出2000,新分配的空间为原空间的三分之一[新分配空间依赖具体实现].
    return 0;
}

源码4

一直在重申[capacity]的值依赖具体实现,因此可能不同平台,输出结果不同.每个vector的实现策略不同(比如gcc,ms vc),但是必须遵守一个原则:只有当迫不得已时才会分配新内存空间.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*************************************************************************
    > File Name: test.9.39.cpp
    > Author: puruidong
    > Mail: 1@w1520.com
    > Created Time: 2014年05月22日 星期四
 ************************************************************************/

#include<iostream>
#include<vector>
using namespace std;

int main()
{
    /*
   
    解释下面的程序片段做了什么?
    1.要求系统分配一个1024大小的空间;
    2.向vector中添加1048个元素;
    3.缩小元素空间,vector中的实际元素是1048个,由于除法是优先运算的,
    因此3的运算结果大致是1048+1048/2=1572.
    *****************************************************************
    此处vector实际元素已经超出了预先分配的空间,因此必须新分配内存空间,新分配的空间长度不少于元素的个数.
    而capacity的值也会发生变化,{这依赖具体实现}.capacity在此处输出:2048[在实际元素数量上增加了1000个内存空间].

    */
    vector<string> svec;
    svec.reserve(1024);//1
    //while(cin >> word)
    for(unsigned i=0;i!=1048;++i)//2
    {
        svec.push_back(i+"test");
    }
    svec.resize(svec.size()+svec.size()/2);//3
    cout << "test>>" << svec.size() << endl;
    cout << "capacity>>" << svec.capacity() << endl;//4
    return 0;
}

关于capacity还有很多问题值得思考,上面的程序在gcc 4.8.2上测试通过[使用C++11进行编译].

JavaScript:全国城市数组[升级版]

说明

部分资料来自网上,若自行调用,一定要注意城市数组里面的部分下标为空的元素。

下面是源文件,自己整合测试一下就可以了.

html

queryhotelcitylist.js

城市数组.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
/****************
 @author:pruidong
 @date:2014.5.20
 @web:07q.net
***************/

//初始化各个城

var citysFlight=new Array();

citysFlight[0]=new Array('pek','北京','beijing','bj');

citysFlight[1]=new Array('can','广州','guangzhou','gz');

citysFlight[2]=new Array('szx','深圳','shenzhen','sz');

citysFlight[3]=new Array('csx','长沙','changsha','cs');

citysFlight[4]=new Array('ctu','成都','chengdu','cd');

citysFlight[5]=new Array('ckg','重庆','chongqing','cq');

citysFlight[6]=new Array('foc','福州','fuzhou','fz');

citysFlight[7]=new Array('kwe','贵阳','guiyang','gy');

citysFlight[8]=new Array('hak','海口','haikou','hk');

citysFlight[9]=new Array('hgh','杭州','hangzhou','hz');

citysFlight[10]=new Array('kmg','昆明','kunming','km');

citysFlight[11]=new Array('khn','南昌','nanchang','nc');

citysFlight[12]=new Array('nkg','南京','nanjing','nj');

citysFlight[13]=new Array('syx','三亚','sanya','sy');

citysFlight[14]=new Array('sha','上海虹桥','shanghaihongqiao','shhq');

citysFlight[15]=new Array('pvg','上海浦东','shanghaipudong','shpd');

citysFlight[16]=new Array('she','沈阳','shenyang','sy');

citysFlight[17]=new Array('wnz','温州','wenzhou','wz');

citysFlight[18]=new Array('wuh','武汉','wuhan','wh');

citysFlight[19]=new Array('xmn','厦门','xiamen','xm');

citysFlight[20]=new Array('sia','西安','xian','xa');

citysFlight[21]=new Array('cgo','郑州','zhengzhou','zz');

citysFlight[22]=new Array('swa','汕头','sangtou','st');

citysFlight[23]=new Array('tyn','太原','taiyuan','ty');

citysFlight[24]=new Array('tsn','天津','tianjin','tj');

citysFlight[25]=new Array('urc','乌鲁木齐','wulumuqi','wlmq');

citysFlight[26]=new Array('yiw','义乌','yiwu','yw');

citysFlight[27]=new Array('zha','湛江','zhanjiang','zj');

citysFlight[28]=new Array('cgo','长春','changchun','cc');

citysFlight[29]=new Array('dlc','大连','dalian','dl');

citysFlight[30]=new Array('kwl','桂林','guilin','gl');

citysFlight[31]=new Array('hrb','哈尔滨','haerbin','heb');

citysFlight[32]=new Array('hfe','合肥','hefei','hf');

citysFlight[33]=new Array('tna','济南','jinan','jn');

citysFlight[34]=new Array('nng','南宁','nanning','nn');

citysFlight[35]=new Array('ngb','宁波','ningbo','nb');

citysFlight[36]=new Array('tao','青岛','qingdao','qd');

citysFlight[37]=new Array('jmu','佳木斯','jiamusi','jms');

citysFlight[38]=new Array('mdg','牡丹江','mudanjiang','mdj');

citysFlight[39]=new Array('ynj','延吉','yanji','yj');

citysFlight[40]=new Array('het','呼和浩特','huhehaote','hhht');

//国际始发

citysFlight[41]=new Array('icn','首尔','shouer','se');

citysFlight[42]=new Array('cju','济州','jizhou','jz');

citysFlight[43]=new Array('pus','釜山','fushan','fs');

citysFlight[44]=new Array('tae','大邱','daqiu','dq');

citysFlight[45]=new Array('del','新德里','xindeli','xdl');

citysFlight[46]=new Array('kix','大阪','daban','db');

citysFlight[47]=new Array('ngo','名古屋','mingguwu','mgw');

citysFlight[48]=new Array('nrt','东京','dongjing','dj');

citysFlight[49]=new Array('fuk','福冈','fugang','fg');

citysFlight[50]=new Array('HKG','香港','xianggang','xg');

citysFlight[51]=new Array('TPE','台北','taibei','tb');   

citysFlight[52]=new Array('SIN','新加坡','xinjiapo','xjp'); 

citysFlight[53]=new Array('BKK','曼谷','mangu','mg');    

citysFlight[54]=new Array('JKT','雅加达','yajiada','yjd');

citysFlight[55]=new Array('KUL','吉隆坡','jilongpo','jlp'); 

citysFlight[56]=new Array('REP','暹粒','xianli','xl');       

citysFlight[57]=new Array('PNH','金边','jinbian','jb');      

citysFlight[58]=new Array('KTM','加德满都','jiademandu','jdmd');           

citysFlight[59]=new Array('SGN','胡志明','huzhiming','hzm');        

citysFlight[60]=new Array('HAN','河内','henei','hl');    

citysFlight[61]=new Array('MNL','马尼拉','manila','man');       

citysFlight[62]=new Array('RGN','仰光','yanguang','yg');         

citysFlight[63]=new Array('PEN','槟城','bincheng','bc');     

citysFlight[64]=new Array('MLE','马累','male','ml');         

citysFlight[65]=new Array('DEL','新德里','xindeli','xdl');              

citysFlight[66]=new Array('NRT','东京','dongjing','dj'); 

                   

citysFlight[67]=new Array('KIJ','新泻','xinxie','xx');

citysFlight[68]=new Array('TOY','富山','fushan','fs');   

citysFlight[69]=new Array('HIJ','广岛','guangdao','gd');     

citysFlight[70]=new Array('SDJ','仙台','xiantai','xt');          

citysFlight[71]=new Array('CTS','札幌','zhahuang','zh');     



citysFlight[72]=new Array('HKG','迪拜','dibai','db');        

citysFlight[73]=new Array('ALA','阿拉木图','alamitu','almt');              

citysFlight[74]=new Array('IKA','德黑兰','deheilan','dhl');                 

citysFlight[75]=new Array('ISB','伊斯兰堡','yisilanbao','yslb');                           

citysFlight[76]=new Array('FRU','比什凯克','bierkaike','bekk');                        

citysFlight[77]=new Array('ASB','阿什哈巴德','ashenhabade','ashbd');  

citysFlight[78]=new Array('BAK','巴库','baku','bk');                             

citysFlight[79]=new Array('VVO','海参崴','haishenwai','hsw');                               

citysFlight[80]=new Array('OVB','新西伯利亚','xinxiboliya','xxbly');                              

citysFlight[81]=new Array('DYU','杜尚别','dushangbie','dsb');                               

citysFlight[82]=new Array('OSS','奥什','aoshen','as');                               

citysFlight[83]=new Array('TAS','塔什干','tashengan','tsg');                            

citysFlight[84]=new Array('JED','吉达','jida','jd');                             

citysFlight[85]=new Array('DAC','达卡','daka','dk');                             

citysFlight[86]=new Array('SYD','悉尼','xini','xn');     

citysFlight[87]=new Array('BNE','布里斯班','bulisiban','blsb');    

citysFlight[88]=new Array('AKL','奥克兰','aokelan','akl');      

citysFlight[89]=new Array('CDG','巴黎','bali','bl');         

citysFlight[90]=new Array('AMS','阿姆斯特丹','amusitedan','amstd');       

citysFlight[91]=new Array('LAX','洛杉矶','luoshanji','lsj');    

citysFlight[92]=new Array('SVO','莫斯科','mosike','msk');           

citysFlight[93]=new Array('YVR','温哥华','wengehua','wgh');

//国内新增数据
/*********************************

        若自行调用时,一定要注意下面的空数组!!

***********************************/

citysFlight[94]=new Array("aldq","阿里地区","alidiqu","aldq");

citysFlight[95]=new Array("ales","阿拉尔","alaershi","ales");

citysFlight[96]=new Array("ays","安阳","anyangshi","ays");

citysFlight[97]=new Array("altdq","阿勒泰地区","aletaidiqu","altdq");

citysFlight[98]=new Array("aksdq","阿克苏地区","akesudiqu","aksdq");

citysFlight[99]=new Array("aqs","安庆","anqingshi","aqs");

citysFlight[100]=new Array("amtbxzq","澳门特别行政区","aomentebiexingzhengqu","amtbxzq");

citysFlight[101]=new Array("aks","安康","ankangshi","aks");

citysFlight[102]=new Array("ass","安顺","anshunshi","ass");

citysFlight[103]=new Array("ass","鞍山","anshanshi","ass");

citysFlight[104]=new Array("alsm","阿拉善盟","alashanmeng","alsm");

citysFlight[105]=new Array("abzzqzzzz","阿坝","abazangzuqiangzuzizhizhou","abzzqzzzz");

citysFlight[106]=new Array("","","","");

citysFlight[107]=new Array("","","","");

citysFlight[108]=new Array("bss","百色","baiseshi","bss");

citysFlight[109]=new Array("bzs","巴中","bazhongshi","bzs");

citysFlight[110]=new Array("bhs","北海","beihaishi","bhs");

citysFlight[111]=new Array("bjdq","毕节地区","bijiediqu","bjdq");

citysFlight[112]=new Array("bds","保定","baodingshi","bds");

citysFlight[113]=new Array("bzs","亳州","bozhoushi","bzs");

citysFlight[114]=new Array("bzs","滨州","binzhoushi","bzs");

citysFlight[115]=new Array("bxs","本溪","benxishi","bxs");

citysFlight[116]=new Array("bjs","宝鸡","baojishi","bjs");

citysFlight[117]=new Array("bynes","巴彦淖尔","bayannaoershi","bynes");

citysFlight[118]=new Array("byglmgzzz","巴音","bayinguolengmengguzizhizhou","byglmgzzz");

citysFlight[119]=new Array("bts","包头","baotoushi","bts");

citysFlight[120]=new Array("bbs","蚌埠","bengbushi","bbs");

citysFlight[121]=new Array("bss","白山","baishanshi","bss");

citysFlight[122]=new Array("bjs","北京","beijingshi","bjs");

citysFlight[123]=new Array("bss","保山","baoshanshi","bss");

citysFlight[124]=new Array("bcs","白城","baichengshi","bcs");

citysFlight[125]=new Array("bys","白银","baiyinshi","bys");

citysFlight[126]=new Array("betlmgzzz","博尔塔拉","boertalamengguzizhizhou","betlmgzzz");

citysFlight[127]=new Array("","","","");

citysFlight[128]=new Array("","","","");

citysFlight[129]=new Array("chs","巢湖","chaohushi","chs");

citysFlight[130]=new Array("cqs","重庆","chongqingshi","cqs");

citysFlight[131]=new Array("czs","沧州","cangzhoushi","czs");

citysFlight[132]=new Array("czs","潮州","chaozhoushi","czs");

citysFlight[133]=new Array("czs","郴州","chenzhoushi","czs");

citysFlight[134]=new Array("zys","朝阳","zhaoyangshi","zys");

citysFlight[135]=new Array("cds","承德","chengdeshi","cds");

citysFlight[136]=new Array("czs","滁州","chuzhoushi","czs");

citysFlight[137]=new Array("czs","常州","changzhoushi","czs");

citysFlight[138]=new Array("cds","常德","changdeshi","cds");

citysFlight[139]=new Array("cddq","昌都地区","changdoudiqu","cddq");

citysFlight[140]=new Array("czs","池州","chizhoushi","czs");

citysFlight[141]=new Array("cxyzzzz","楚雄","chuxiongyizuzizhizhou","cxyzzzz");

citysFlight[142]=new Array("cjhzzzz","昌吉","changjihuizuzizhizhou","cjhzzzz");

citysFlight[143]=new Array("cds","成都","chengdushi","cds");

citysFlight[144]=new Array("czs","崇左","chongzuoshi","czs");

citysFlight[145]=new Array("cfs","赤峰","chifengshi","cfs");

citysFlight[146]=new Array("","","","");

citysFlight[147]=new Array("","","","");

citysFlight[148]=new Array("dgs","东莞","dongguanshi","dgs");

citysFlight[149]=new Array("dds","丹东","dandongshi","dds");

citysFlight[150]=new Array("dxs","定西","dingxishi","dxs");

citysFlight[151]=new Array("dlbzzzz","大理","dalibaizuzizhizhou","dlbzzzz");

citysFlight[152]=new Array("dxaldq","大兴安岭地区","daxinganlingdiqu","dxaldq");

citysFlight[153]=new Array("dqzzzzz","迪庆藏族自治州","diqingzangzuzizhizhou","dqzzzzz");

citysFlight[154]=new Array("dzs","达州","dazhoushi","dzs");

citysFlight[155]=new Array("dys","德阳","deyangshi","dys");

citysFlight[156]=new Array("dzs","德州","dezhoushi","dzs");

citysFlight[157]=new Array("dhdzjpzzzz","德宏傣族景","dehongdaizujingpozuzizhizhou","dhdzjpzzzz");

citysFlight[158]=new Array("dys","东营","dongyingshi","dys");

citysFlight[159]=new Array("dqs","大庆","daqingshi","dqs");

citysFlight[160]=new Array("dts","大同","datongshi","dts");

citysFlight[161]=new Array("dls","大连","dalianshi","dls");

citysFlight[162]=new Array("","","","");

citysFlight[163]=new Array("","","","");

citysFlight[164]=new Array("estjzmzzzz","恩施","enshitujiazumiaozuzizhizhou","estjzmzzzz");

citysFlight[165]=new Array("eedss","鄂尔多斯","eerduosishi","eedss");

citysFlight[166]=new Array("ezs","鄂州","ezhoushi","ezs");

citysFlight[167]=new Array("","","","");

citysFlight[168]=new Array("","","","");

citysFlight[169]=new Array("fzs","福州","fuzhoushi","fzs");

citysFlight[170]=new Array("fxs","阜新","fuxinshi","fxs");

citysFlight[171]=new Array("fss","抚顺","fushunshi","fss");

citysFlight[172]=new Array("fys","阜阳","fuyangshi","fys");

citysFlight[173]=new Array("fzs","抚州","fuzhoushi","fzs");

citysFlight[174]=new Array("fcgs","防城港","fangchenggangshi","fcgs");

citysFlight[175]=new Array("fss","佛山","foshanshi","fss");

citysFlight[176]=new Array("","","","");

citysFlight[177]=new Array("","","","");

citysFlight[178]=new Array("gzs","赣州","ganzhoushi","gzs");

citysFlight[179]=new Array("gzs","广州","guangzhoushi","gzs");

citysFlight[180]=new Array("gys","贵阳","guiyangshi","gys");

citysFlight[181]=new Array("glzzzzz","果洛","guoluozangzuzizhizhou","glzzzzz");

citysFlight[182]=new Array("gys","固原","guyuanshi","gys");

citysFlight[183]=new Array("gls","桂林","guilinshi","gls");

citysFlight[184]=new Array("gas","广安","guanganshi","gas");

citysFlight[185]=new Array("gzzzzzz","甘孜","ganzizangzuzizhizhou","gzzzzzz");

citysFlight[186]=new Array("gys","广元","guangyuanshi","gys");

citysFlight[187]=new Array("ggs","贵港","guigangshi","ggs");

citysFlight[188]=new Array("gnzzzzz","甘南","gannanzangzuzizhizhou","gnzzzzz");

citysFlight[189]=new Array("","","","");

citysFlight[190]=new Array("","","","");

citysFlight[191]=new Array("hhs","怀化","huaihuashi","hhs");

citysFlight[192]=new Array("hfs","合肥","hefeishi","hfs");

citysFlight[193]=new Array("hgs","黄冈","huanggangshi","hgs");

citysFlight[194]=new Array("hlds","葫芦岛","huludaoshi","hlds");

citysFlight[195]=new Array("hmdq","哈密地区","hamidiqu","hmdq");

citysFlight[196]=new Array("hhhts","呼和浩特","huhehaoteshi","hhhts");

citysFlight[197]=new Array("has","淮安","huaianshi","has");

citysFlight[198]=new Array("hbs","鹤壁","hebishi","hbs");

citysFlight[199]=new Array("hzs","贺州","hezhoushi","hzs");

citysFlight[200]=new Array("hzs","荷泽","hezeshi","hzs");

citysFlight[201]=new Array("hebs","哈尔滨","haerbinshi","hebs");

citysFlight[202]=new Array("hbzzzzz","海北","haibeizangzuzizhizhou","hbzzzzz");

citysFlight[203]=new Array("hnzzzzz","海南","hainanzangzuzizhizhou","hnzzzzz");

citysFlight[204]=new Array("hzs","杭州","hangzhoushi","hzs");

citysFlight[205]=new Array("hnzzzzz","黄南","huangnanzangzuzizhizhou","hnzzzzz");

citysFlight[206]=new Array("htdq","和田地区","hetiandiqu","htdq");

citysFlight[207]=new Array("hxmgzzzzzz","海西","haiximengguzuzangzuzizhizhou","hxmgzzzzzz");

citysFlight[208]=new Array("hds","邯郸","handanshi","hds");

citysFlight[209]=new Array("hhhnzyzzzz","红河","honghehanizuyizuzizhizhou","hhhnzyzzzz");

citysFlight[210]=new Array("hcs","河池","hechishi","hcs");

citysFlight[211]=new Array("hgs","鹤岗","hegangshi","hgs");

citysFlight[212]=new Array("hss","衡水","hengshuishi","hss");

citysFlight[213]=new Array("hddq","海东地区","haidongdiqu","hddq");

citysFlight[214]=new Array("hks","海口","haikoushi","hks");

citysFlight[215]=new Array("hzs","湖州","huzhoushi","hzs");

citysFlight[216]=new Array("hss","黄山","huangshanshi","hss");

citysFlight[217]=new Array("hbs","淮北","huaibeishi","hbs");

citysFlight[218]=new Array("hlbes","呼伦贝尔","hulunbeiershi","hlbes");

citysFlight[219]=new Array("hys","衡阳","hengyangshi","hys");

citysFlight[220]=new Array("hns","淮南","huainanshi","hns");

citysFlight[221]=new Array("hhs","黑河","heiheshi","hhs");

citysFlight[222]=new Array("hzs","汉中","hanzhongshi","hzs");

citysFlight[223]=new Array("hys","河源","heyuanshi","hys");

citysFlight[224]=new Array("hzs","惠州","huizhoushi","hzs");

citysFlight[225]=new Array("hss","黄石","huangshishi","hss");

citysFlight[226]=new Array("","","","");

citysFlight[227]=new Array("","","","");

citysFlight[228]=new Array("jzs","锦州","jinzhoushi","jzs");

citysFlight[229]=new Array("jns","济南","jinanshi","jns");

citysFlight[230]=new Array("jns","济宁","jiningshi","jns");

citysFlight[231]=new Array("jjs","九江","jiujiangshi","jjs");

citysFlight[232]=new Array("jhs","金华","jinhuashi","jhs");

citysFlight[233]=new Array("jcs","金昌","jinchangshi","jcs");

citysFlight[234]=new Array("jxs","鸡西","jixishi","jxs");

citysFlight[235]=new Array("jms","江门","jiangmenshi","jms");

citysFlight[236]=new Array("jygs","嘉峪关","jiayuguanshi","jygs");

citysFlight[237]=new Array("jcs","晋城","jinchengshi","jcs");

citysFlight[238]=new Array("jxs","嘉兴","jiaxingshi","jxs");

citysFlight[239]=new Array("jdzs","景德镇","jingdezhenshi","jdzs");

citysFlight[240]=new Array("jmss","佳木斯","jiamusishi","jmss");

citysFlight[241]=new Array("jas","吉安","jianshi","jas");

citysFlight[242]=new Array("jzs","焦作","jiaozuoshi","jzs");

citysFlight[243]=new Array("jms","荆门","jingmenshi","jms");

citysFlight[244]=new Array("jys","揭阳","jieyangshi","jys");

citysFlight[245]=new Array("jls","吉林","jilinshi","jls");

citysFlight[246]=new Array("jqs","酒泉","jiuquanshi","jqs");

citysFlight[247]=new Array("jzs","晋中","jinzhongshi","jzs");

citysFlight[248]=new Array("jzs","荆州","jingzhoushi","jzs");

citysFlight[249]=new Array("","","","");

citysFlight[250]=new Array("","","","");

citysFlight[251]=new Array("kfs","开封","kaifengshi","kfs");

citysFlight[252]=new Array("klmys","克拉玛依","kelamayishi","klmys");

citysFlight[253]=new Array("kms","昆明","kunmingshi","kms");

citysFlight[254]=new Array("kzlskekzzzz","克孜勒苏柯尔克孜","kezilesukeerkezizizhizhou","kzlskekzzzz");

citysFlight[255]=new Array("ksdq","喀什地区","kashidiqu","ksdq");

citysFlight[256]=new Array("","","","");

citysFlight[257]=new Array("","","","");

citysFlight[258]=new Array("lss","拉萨","lasashi","lss");

citysFlight[259]=new Array("lygs","连云港","lianyungangshi","lygs");

citysFlight[260]=new Array("ljs","丽江","lijiangshi","ljs");

citysFlight[261]=new Array("lhs","漯河","luoheshi","lhs");

citysFlight[262]=new Array("lzs","兰州","lanzhoushi","lzs");

citysFlight[263]=new Array("las","六安","liuanshi","las");

citysFlight[264]=new Array("lzdq","林芝地区","linzhidiqu","lzdq");

citysFlight[265]=new Array("lys","辽源","liaoyuanshi","lys");

citysFlight[266]=new Array("lds","娄底","loudishi","lds");

citysFlight[267]=new Array("lfs","廊坊","langfangshi","lfs");

citysFlight[268]=new Array("lss","丽水","lishuishi","lss");

citysFlight[269]=new Array("lys","辽阳","liaoyangshi","lys");

citysFlight[270]=new Array("lys","临沂","linyishi","lys");

citysFlight[271]=new Array("lzs","柳州","liuzhoushi","lzs");

citysFlight[272]=new Array("lpss","六盘水","liupanshuishi","lpss");

citysFlight[273]=new Array("lys","洛阳","luoyangshi","lys");

citysFlight[274]=new Array("lns","陇南","longnanshi","lns");

citysFlight[275]=new Array("lsyzzzz","凉山","liangshanyizuzizhizhou","lsyzzzz");

citysFlight[276]=new Array("lcs","临沧","lincangshi","lcs");

citysFlight[277]=new Array("lxhzzzz","临夏","linxiahuizuzizhizhou","lxhzzzz");

citysFlight[278]=new Array("lcs","聊城","liaochengshi","lcs");

citysFlight[279]=new Array("lys","龙岩","longyanshi","lys");

citysFlight[280]=new Array("lfs","临汾","linfenshi","lfs");

citysFlight[281]=new Array("lls","吕梁","lvliangshi","lls");

citysFlight[282]=new Array("lzs","泸州","luzhoushi","lzs");

citysFlight[283]=new Array("lws","莱芜","laiwushi","lws");

citysFlight[284]=new Array("lss","乐山","leshanshi","lss");

citysFlight[285]=new Array("lbs","来宾","laibinshi","lbs");

citysFlight[286]=new Array("","","","");

citysFlight[287]=new Array("","","","");

citysFlight[288]=new Array("mass","马鞍山","maanshanshi","mass");

citysFlight[289]=new Array("mms","茂名","maomingshi","mms");

citysFlight[290]=new Array("mys","绵阳","mianyangshi","mys");

citysFlight[291]=new Array("mss","眉山","meishanshi","mss");

citysFlight[292]=new Array("mzs","梅州","meizhoushi","mzs");

citysFlight[293]=new Array("mdjs","牡丹江","mudanjiangshi","mdjs");

citysFlight[294]=new Array("","","","");

citysFlight[295]=new Array("","","","");

citysFlight[296]=new Array("nps","南平","nanpingshi","nps");

citysFlight[297]=new Array("nds","宁德","ningdeshi","nds");

citysFlight[298]=new Array("ncs","南昌","nanchangshi","ncs");

citysFlight[299]=new Array("nts","南通","nantongshi","nts");

citysFlight[300]=new Array("njs","南京","nanjingshi","njs");

citysFlight[301]=new Array("nys","南阳","nanyangshi","nys");

citysFlight[302]=new Array("nns","南宁","nanningshi","nns");

citysFlight[303]=new Array("njlszzzz","怒江","nujianglisuzuzizhizhou","njlszzzz");

citysFlight[304]=new Array("njs","内江","neijiangshi","njs");

citysFlight[305]=new Array("nbs","宁波","ningboshi","nbs");

citysFlight[306]=new Array("nqdq","那曲地区","naqudiqu","nqdq");

citysFlight[307]=new Array("ncs","南充","nanchongshi","ncs");

citysFlight[308]=new Array("","","","");

citysFlight[309]=new Array("","","","");

citysFlight[310]=new Array("pxs","萍乡","pingxiangshi","pxs");

citysFlight[311]=new Array("pls","平凉","pingliangshi","pls");

citysFlight[312]=new Array("pzhs","攀枝花","panzhihuashi","pzhs");

citysFlight[313]=new Array("pys","濮阳","puyangshi","pys");

citysFlight[314]=new Array("pjs","盘锦","panjinshi","pjs");

citysFlight[315]=new Array("pts","莆田","putianshi","pts");

citysFlight[316]=new Array("pdss","平顶山","pingdingshanshi","pdss");

citysFlight[317]=new Array("","","","");

citysFlight[318]=new Array("","","","");

citysFlight[319]=new Array("qzs","钦州","qinzhoushi","qzs");

citysFlight[320]=new Array("qzs","衢州","quzhoushi","qzs");

citysFlight[321]=new Array("qys","清远","qingyuanshi","qys");

citysFlight[322]=new Array("qqhes","齐齐哈尔","qiqihaershi","qqhes");

citysFlight[323]=new Array("qnbyzmzzzz","黔南","qiannanbuyizumiaozuzizhizhou","qnbyzmzzzz");

citysFlight[324]=new Array("qths","七台河","qitaiheshi","qths");

citysFlight[325]=new Array("qds","青岛","qingdaoshi","qds");

citysFlight[326]=new Array("qdnmzdzzzz","黔东南","qiandongnanmiaozudongzuzizhizhou","qdnmzdzzzz");

citysFlight[327]=new Array("qhds","秦皇岛","qinhuangdaoshi","qhds");

citysFlight[328]=new Array("qys","庆阳","qingyangshi","qys");

citysFlight[329]=new Array("qxnbyzmzzzz","黔西南","qianxinanbuyizumiaozuzizhizhou","qxnbyzmzzzz");

citysFlight[330]=new Array("qjs","曲靖","qujingshi","qjs");

citysFlight[331]=new Array("qzs","泉州","quanzhoushi","qzs");

citysFlight[332]=new Array("","","","");

citysFlight[333]=new Array("","","","");

citysFlight[334]=new Array("rzs","日照","rizhaoshi","rzs");

citysFlight[335]=new Array("rkzdq","日喀则地区","rikazediqu","rkzdq");

citysFlight[336]=new Array("","","","");

citysFlight[337]=new Array("","","","");

citysFlight[338]=new Array("sgs","韶关","shaoguanshi","sgs");

citysFlight[339]=new Array("shzs","石河子","shihezishi","shzs");

citysFlight[340]=new Array("sndq","山南地区","shannandiqu","sndq");

citysFlight[341]=new Array("szss","石嘴山","shizuishanshi","szss");

citysFlight[342]=new Array("syss","双鸭山","shuangyashanshi","syss");

citysFlight[343]=new Array("szs","深圳","shenzhenshi","szs");

citysFlight[344]=new Array("sms","三明","sanmingshi","sms");

citysFlight[345]=new Array("shs","上海","shanghaishi","shs");

citysFlight[346]=new Array("sxs","绍兴","shaoxingshi","sxs");

citysFlight[347]=new Array("shs","绥化","suihuashi","shs");

citysFlight[348]=new Array("szs","苏州","suzhoushi","szs");

citysFlight[349]=new Array("szs","宿州","suzhoushi","szs");

citysFlight[350]=new Array("snj","神农架","shennongjia","snj");

citysFlight[351]=new Array("sys","邵阳","shaoyangshi","sys");

citysFlight[352]=new Array("sys","十堰","shiyanshi","sys");

citysFlight[353]=new Array("sws","汕尾","shanweishi","sws");

citysFlight[354]=new Array("srs","上饶","shangraoshi","srs");

citysFlight[355]=new Array("sps","四平","sipingshi","sps");

citysFlight[356]=new Array("sjzs","石家庄","shijiazhuangshi","sjzs");

citysFlight[357]=new Array("szs","随州","suizhoushi","szs");

citysFlight[358]=new Array("smxs","三门峡","sanmenxiashi","smxs");

citysFlight[359]=new Array("sts","汕头","shantoushi","sts");

citysFlight[360]=new Array("sns","遂宁","suiningshi","sns");

citysFlight[361]=new Array("sqs","商丘","shangqiushi","sqs");

citysFlight[362]=new Array("szs","朔州","shuozhoushi","szs");

citysFlight[363]=new Array("sms","思茅","simaoshi","sms");

citysFlight[364]=new Array("sys","沈阳","shenyangshi","sys");

citysFlight[365]=new Array("sls","商洛","shangluoshi","sls");

citysFlight[366]=new Array("sys","三亚","sanyashi","sys");

citysFlight[367]=new Array("sqs","宿迁","suqianshi","sqs");

citysFlight[368]=new Array("sys","松原","songyuanshi","sys");

citysFlight[369]=new Array("xms","厦门","xiamenshi","xms");

citysFlight[370]=new Array("","","","");

citysFlight[371]=new Array("","","","");

citysFlight[372]=new Array("tys","太原","taiyuanshi","tys");

citysFlight[373]=new Array("tmsks","图木舒克","tumushukeshi","tmsks");

citysFlight[374]=new Array("tls","通辽","tongliaoshi","tls");

citysFlight[375]=new Array("tcdq","塔城地区","tachengdiqu","tcdq");

citysFlight[376]=new Array("tlfdq","吐鲁番地区","tulufandiqu","tlfdq");

citysFlight[377]=new Array("tzs","泰州","taizhoushi","tzs");

citysFlight[378]=new Array("ths","通化","tonghuashi","ths");

citysFlight[379]=new Array("tzs","台州","taizhoushi","tzs");

citysFlight[380]=new Array("tls","铜陵","tonglingshi","tls");

citysFlight[381]=new Array("tjs","天津","tianjinshi","tjs");

citysFlight[382]=new Array("tls","铁岭","tielingshi","tls");

citysFlight[383]=new Array("tcs","铜川","tongchuanshi","tcs");

citysFlight[384]=new Array("tas","泰安","taianshi","tas");

citysFlight[385]=new Array("tss","唐山","tangshanshi","tss");

citysFlight[386]=new Array("trdq","铜仁地区","tongrendiqu","trdq");

citysFlight[387]=new Array("tss","天水","tianshuishi","tss");

citysFlight[388]=new Array("tws","台湾省","taiwansheng","tws");

citysFlight[389]=new Array("","","","");

citysFlight[390]=new Array("","","","");

citysFlight[391]=new Array("wzs","温州","wenzhoushi","wzs");

citysFlight[392]=new Array("whs","武汉","wuhanshi","whs");

citysFlight[393]=new Array("wws","武威","wuweishi","wws");

citysFlight[394]=new Array("wlmqs","乌鲁木齐","wulumuqishi","wlmqs");

citysFlight[395]=new Array("wjqs","五家渠","wujiaqushi","wjqs");

citysFlight[396]=new Array("whs","威海","weihaishi","whs");

citysFlight[397]=new Array("whs","芜湖","wuhushi","whs");

citysFlight[398]=new Array("wzs","梧州","wuzhoushi","wzs");

citysFlight[399]=new Array("wxs","无锡","wuxishi","wxs");

citysFlight[400]=new Array("whs","乌海","wuhaishi","whs");

citysFlight[401]=new Array("wfs","潍坊","weifangshi","wfs");

citysFlight[402]=new Array("wzs","吴忠","wuzhongshi","wzs");

citysFlight[403]=new Array("wlcbs","乌兰察布","wulanchabushi","wlcbs");

citysFlight[404]=new Array("wns","渭南","weinanshi","wns");

citysFlight[405]=new Array("wszzmzzzz","文山","wenshanzhuangzumiaozuzizhizhou","wszzmzzzz");

citysFlight[406]=new Array("","","","");

citysFlight[407]=new Array("","","","");

citysFlight[408]=new Array("xts","湘潭","xiangtanshi","xts");

citysFlight[409]=new Array("xlglm","锡林郭勒盟","xilinguolemeng","xlglm");

citysFlight[410]=new Array("xzs","徐州","xuzhoushi","xzs");

citysFlight[411]=new Array("xzs","忻州","xinzhoushi","xzs");

citysFlight[412]=new Array("xfs","襄樊","xiangfanshi","xfs");

citysFlight[413]=new Array("xys","信阳","xinyangshi","xys");

citysFlight[414]=new Array("xas","西安","xianshi","xas");

citysFlight[415]=new Array("xxs","新乡","xinxiangshi","xxs");

citysFlight[416]=new Array("xxtjzmzzzz","湘西","xiangxitujiazumiaozuzizhizhou","xxtjzmzzzz");

citysFlight[417]=new Array("xts","邢台","xingtaishi","xts");

citysFlight[418]=new Array("xys","新余","xinyushi","xys");

citysFlight[419]=new Array("xam","兴安盟","xinganmeng","xam");

citysFlight[420]=new Array("xcs","许昌","xuchangshi","xcs");

citysFlight[421]=new Array("xcs","宣城","xuanchengshi","xcs");

citysFlight[422]=new Array("xgs","孝感","xiaoganshi","xgs");

citysFlight[423]=new Array("xns","西宁","xiningshi","xns");

citysFlight[424]=new Array("xys","咸阳","xianyangshi","xys");

citysFlight[425]=new Array("xns","咸宁","xianningshi","xns");

citysFlight[426]=new Array("xgtbxzq","香港特别行政区","xianggangtebiexingzhengqu","xgtbxzq");

citysFlight[427]=new Array("xsbndzzzz","西双版纳","xishuangbannadaizuzizhizhou","xsbndzzzz");

citysFlight[428]=new Array("","","","");

citysFlight[429]=new Array("","","","");

citysFlight[430]=new Array("ycs","宜昌","yichangshi","ycs");

citysFlight[431]=new Array("ycs","伊春","yichunshi","ycs");

citysFlight[432]=new Array("yas","雅安","yaanshi","yas");

citysFlight[433]=new Array("ycs","宜春","yichunshi","ycs");

citysFlight[434]=new Array("yszzzzz","玉树藏族自治州","yushuzangzuzizhizhou","yszzzzz");

citysFlight[435]=new Array("ycs","盐城","yanchengshi","ycs");

citysFlight[436]=new Array("yts","烟台","yantaishi","yts");

citysFlight[437]=new Array("yts","鹰潭","yingtanshi","yts");

citysFlight[438]=new Array("yzs","扬州","yangzhoushi","yzs");

citysFlight[439]=new Array("yks","营口","yingkoushi","yks");

citysFlight[440]=new Array("ycs","银川","yinchuanshi","ycs");

citysFlight[441]=new Array("ycs","运城","yunchengshi","ycs");

citysFlight[442]=new Array("yys","益阳","yiyangshi","yys");

citysFlight[443]=new Array("yls","玉林","yulinshi","yls");

citysFlight[444]=new Array("yqs","阳泉","yangquanshi","yqs");

citysFlight[445]=new Array("yjs","阳江","yangjiangshi","yjs");

citysFlight[446]=new Array("ybcxzzzz","延边","yanbianchaoxianzuzizhizhou","ybcxzzzz");

citysFlight[447]=new Array("yxs","玉溪","yuxishi","yxs");

citysFlight[448]=new Array("ybs","宜宾","yibinshi","ybs");

citysFlight[449]=new Array("yfs","云浮","yunfushi","yfs");

citysFlight[450]=new Array("yzs","永州","yongzhoushi","yzs");

citysFlight[451]=new Array("yys","岳阳","yueyangshi","yys");

citysFlight[452]=new Array("yls","榆林","yulinshi","yls");

citysFlight[453]=new Array("yas","延安","yananshi","yas");

citysFlight[454]=new Array("ylhskzzz","伊犁","yilihasakezizhizhou","ylhskzzz");

citysFlight[455]=new Array("","","","");

citysFlight[456]=new Array("","","","");

citysFlight[457]=new Array("zjjs","张家界","zhangjiajieshi","zjjs");

citysFlight[458]=new Array("czs","长治","changzhishi","czs");

citysFlight[459]=new Array("zjs","湛江","zhanjiangshi","zjs");

citysFlight[460]=new Array("zss","中山","zhongshanshi","zss");

citysFlight[461]=new Array("zmds","驻马店","zhumadianshi","zmds");

citysFlight[462]=new Array("zqs","肇庆","zhaoqingshi","zqs");

citysFlight[463]=new Array("ccs","长春","changchunshi","ccs");

citysFlight[464]=new Array("zbs","淄博","ziboshi","zbs");

citysFlight[465]=new Array("zss","舟山","zhoushanshi","zss");

citysFlight[466]=new Array("zgs","自贡","zigongshi","zgs");

citysFlight[467]=new Array("zys","资阳","ziyangshi","zys");

citysFlight[468]=new Array("zhs","珠海","zhuhaishi","zhs");

citysFlight[469]=new Array("zks","周口","zhoukoushi","zks");

citysFlight[470]=new Array("zys","张掖","zhangyeshi","zys");

citysFlight[471]=new Array("zzs","郑州","zhengzhoushi","zzs");

citysFlight[472]=new Array("zys","遵义","zunyishi","zys");

citysFlight[473]=new Array("css","长沙","changshashi","css");

citysFlight[474]=new Array("zzs","株洲","zhuzhoushi","zzs");

citysFlight[475]=new Array("zzs","漳州","zhangzhoushi","zzs");

citysFlight[476]=new Array("zzs","枣庄","zaozhuangshi","zzs");

citysFlight[477]=new Array("zts","昭通","zhaotongshi","zts");

citysFlight[478]=new Array("zws","中卫","zhongweishi","zws");

citysFlight[479]=new Array("zjks","张家口","zhangjiakoushi","zjks");

citysFlight[480]=new Array("zjs","镇江","zhenjiangshi","zjs");

queryticketcity.js

城市操作js.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
(function($){
        //城市操作js.

    $.querycity = function(input,options){

        var input = $(".choosesetout");//触发城市选择框.可以是按钮.

        var sousuo = $(".Sousuocity");//城市返回框.

        input.attr('autocomplete','off');

       

        /*

        if($.trim(input.val())=='' || $.trim(input.val())==options.defaultText){

            input.val(options.defaultText).css('color','#aaa');

        }

        */

        var t_pop_focus = false;

        var t_suggest_focus = false;

        var t_suggest_page_click = false;//display:none

        $('body').append("<div id='pop_city_"+input.attr('id')+"' class='pop_city' style='display:none'><p class='pop_head'></p><ul class='list_label'></ul><div class='pop_city_container'></div></div>");

        $('body').append("<div id='suggest_city_"+input.attr('id')+"' class='list_city' style='display:none'><div class='list_city_head'></div><div class='list_city_container'></div><div class='page_break'></div></div>");

        var popMain = $("#pop_city_"+input.attr('id'))

        var popContainer = popMain.find('.pop_city_container');

        var labelMain = popMain.find('.list_label');

        var suggestMain = $("#suggest_city_"+input.attr('id'));

        popMain.bgIframe();

        suggestMain.bgIframe();

        popInit();

        resetPosition();        

       

        $(window).resize(function(){

            resetPosition();

        });        

       

        input.focus(function(){

            if(t_suggest_page_click){

                t_suggest_page_click = false;

                return true;

            }

            suggestMain.hide();

            if($.trim($(this).val())==options.defaultText){

                $(this).val('').css('color','#000');

            }

            popMain.show();

        }).click(function(){       

            if(t_suggest_page_click){

                t_suggest_page_click = false;

                return;

            }

            suggestMain.hide();

            popMain.show();    

        }).blur(function(){            

            if(t_pop_focus == false){

                popMain.hide();            

                if($.trim(input.val())=='' || $.trim(input.val())==options.defaultText){               

                    input.val(options.defaultText).css('color','#aaa');

                }

            }

        });

        labelMain.find('a').live('click',function(){   

            input.focus();//使焦点在输入框,避免blur事件无法触发

            t_pop_focus = true;

            var labelId = $(this).attr('id');

            labelMain.find('li a').removeClass('current');

            $(this).addClass('current');

            popContainer.find('ul').hide();

            $("#"+labelId+'_container').show();

           

        });

        popContainer.find('a').live('click',function(){

           

            input.text($(this).html());//将城市加载到元素

            sousuo.val($(this).html());//将城市加载到元素.

            //alert($(this).html());//输出选择城市

            /////////////////////////////

            popMain.hide();

        });

        popMain.mouseover(function(){  

            t_pop_focus = true;

        }).mouseout(function(){

            t_pop_focus = false;

        });



        input.blur(function(){

            if( t_suggest_focus == false ){

                if($(this).val()==''){

                    $(this).val( suggestMain.find('.list_city_container a.selected').children('b').text());

                }

            suggestMain.hide();

            }

        }).keydown(function(event){

            popMain.hide();

            event = window.event || event;

            var keyCode = event.keyCode || event.which || event.charCode;      

            if (keyCode == 37) {//左

                prevPage();    

            } else if (keyCode == 39) {//右

                nextPage();

            }else if(keyCode == 38){//上

                prevResult();

            }else if(keyCode == 40){//下

                 nextResult();

            }

        }).keypress(function(event){

            event = window.event || event;

            var keyCode = event.keyCode || event.which || event.charCode;

            if(13 == keyCode){

                if(suggestMain.find('.list_city_container a.selected').length > 0){

                    input.val(suggestMain.find('.list_city_container a.selected').children('b').text());

                    suggestMain.hide();

                }

            }

        }).keyup(function(event){

            event = window.event || event;

            var keyCode = event.keyCode || event.which || event.charCode;        

            if(keyCode != 13 && keyCode != 37 && keyCode != 39 && keyCode !=9 && keyCode !=38 && keyCode !=40 ){

                //keyCode == 9是tab切换键

                queryCity();

            }

        });

     

        suggestMain.find('.list_city_container a').live('click',function(){

            input.val($(this).children('b').text());

            suggestMain.hide();

           

        }).live('mouseover',function(){

            t_suggest_focus = true;        

        }).live('mouseout',function(){

            t_suggest_focus = false;

        });

        suggestMain.find('.page_break a').live('mouseover',function(){

            t_suggest_focus = true;        

        }).live('mouseout',function(){

            t_suggest_focus = false;

        });

        suggestMain.find('.page_break a').live('click',function(event){

            t_suggest_page_click = true;

            input.click();

            if($(this).attr('inum') != null){

                setAddPage($(this).attr('inum'));

            }

        });



        function nextPage(){

              var add_cur= suggestMain.find(".page_break a.current").next();

                if (add_cur != null) {                

                    if ($(add_cur).attr("inum") != null) {

                        setAddPage($(add_cur).attr("inum"));

                    }

                }

        }

        function prevPage(){

                var add_cur = suggestMain.find(".page_break a.current").prev();

                if (add_cur != null) {

                    if ($(add_cur).attr("inum") != null) {

                        setAddPage($(add_cur).attr("inum"));

                    }

                }

        }

        function nextResult(){

                  var t_index = suggestMain.find('.list_city_container a').index(suggestMain.find('.list_city_container a.selected')[0]);

                    suggestMain.find('.list_city_container').children().removeClass('selected');          

                    t_index += 1;

                    var t_end =  suggestMain.find('.list_city_container a').index( suggestMain.find('.list_city_container a:visible').filter(':last')[0]);

                    if(t_index > t_end ){

                        t_index = suggestMain.find('.list_city_container a').index(suggestMain.find('.list_city_container a:visible').eq(0));

                    }

                    suggestMain.find('.list_city_container a').eq(t_index).addClass('selected');

        }

        function prevResult(){

                 

                     var t_index = suggestMain.find('.list_city_container a').index(suggestMain.find('.list_city_container a.selected')[0]);

                suggestMain.find('.list_city_container').children().removeClass('selected');

                t_index -= 1;

                var t_start = suggestMain.find('.list_city_container a').index(suggestMain.find('.list_city_container a:visible').filter(':first')[0]);

                if( t_index < t_start){

                    t_index = suggestMain.find('.list_city_container a').index(suggestMain.find('.list_city_container a:visible').filter(':last')[0]);

                }

                suggestMain.find('.list_city_container a').eq(t_index).addClass('selected');      

        }

        function loadCity(){       

            var cityList = suggestMain.find('.list_city_container');       

            cityList.empty();

            if(options.hotList){

                var hotList = options.hotList;

            }else{

                var hotList = [0,1,2,3,4,5,6,7,8,9];

            }

            for(var item in hotList){

                if(item>options.suggestLength){

                    return;

                }

                var _data = options.data[hotList[item]];

                cityList.append("<a href='javascript:void(0)' ><span>"+_data[2]+"</span><b>"+_data[1]+"</b></a>");

            }      

            suggestMain.find('.list_city_head').html(options.suggestTitleText);

            setAddPage(1);

            suggestMain.show();

            setTopSelect();

        }

        function queryCity(){

            popMain.hide();

            var value = input.val().toLowerCase();

            if( value.length == 0){

                loadCity();

                return;

            }

            var city_container = suggestMain.find('.list_city_container');        

            var isHave = false;

            var _tmp = new Array();

            for(var item in options.data){         

                var _data = options.data[item];    

                if(typeof (_data) != 'undefined'){

                    if(_data[2].indexOf(value) >= 0 || _data[3].indexOf(value) >= 0 || _data[1].indexOf(value) >=0 || _data[0].indexOf(value) >=0 ){                                       

                        isHave = true;

                        _tmp.push(_data);

                    }

                }

             }

;

            if(isHave){

                city_container.empty();

                for(var item in _tmp){

                var _data= _tmp[item];

                city_container.append("<a href='javascript:void(0)' style='display:none'><span>"+_data[2]+"</span><b>"+     _data[1] +"</b></a>");                

                }

                suggestMain.find('.list_city_head').html(value+",按拼音排序");

                setAddPage(1);

                setTopSelect()

            }else{

                suggestMain.find('.list_city_head').html("<span class='msg'>对不起,找不到"+value+"</span>");

            }

            suggestMain.show();

        }

        function setAddPage(pageIndex){

            suggestMain.find('.list_city_container a').removeClass('selected');

            suggestMain.find('.list_city_container').children().each(function(i){          

                var k = i+1;

                if(k> options.suggestLength*(pageIndex-1) && k <= options.suggestLength*pageIndex){

                    $(this).css('display','block');

                }else{

                    $(this).hide();    

                }

             });

            setTopSelect();

            setAddPageHtml(pageIndex);

        }

        function setAddPageHtml(pageIndex){

            var cityPageBreak = suggestMain.find('.page_break');

            cityPageBreak.empty(); 

            if(suggestMain.find('.list_city_container').children().length > options.suggestLength){

                var pageBreakSize = Math.ceil(suggestMain.find('.list_city_container').children().length/options.suggestLength);   

                if(pageBreakSize <= 1){

                    return;

                }          

                var start = end = pageIndex;

                for(var index = 0 ,num = 1 ; index < options.pageLength && num < options.pageLength; index++){

                    if(start > 1){

                        start--;num++;

                    }

                    if(end<pageBreakSize){

                        end ++;num++;

                    }

                }

                if(pageIndex > 1){

                    cityPageBreak.append("<a href='javascript:void(0)' inum='"+(pageIndex-1)+"'>&lt;-</a>");

                }  

                for(var i=start;i<=end;i++){

                    if(i == pageIndex){

                        cityPageBreak.append("<a href='javascript:void(0)' class='current' inum='"+(i)+"'>"+(i)+"</a");

                    }else{

                        cityPageBreak.append("<a href='javascript:void(0)' inum='"+(i)+"'>"+(i)+"</a");

                    }        

             }        

                if (pageIndex<pageBreakSize) {

                    cityPageBreak.append("<a href='javascript:void(0);' inum='"+ (i) +"'>-&gt;</a>");

                }

                cityPageBreak.show();          

            }else{

                cityPageBreak.hide();    

            }

            return;

        }

        function setTopSelect(){       

            if(suggestMain.find('.list_city_container').children().length > 0 ){

                suggestMain.find('.list_city_container').children(':visible').eq(0).addClass('selected');

            }

        }

        function onSelect(){

            if( typeof options.onSelect == 'function'){

                alert(1);

            }

        }

        function popInit(){

            var index = 0;

            popMain.find('.pop_head').html(options.popTitleText);

            if(!options.tabs){

                popContainer.append("<ul id='label_"+input.attr('id')+"_container' class='current'></ul>");

                labelMain.remove();

                for( var item in options.data){

                      $("#label_"+input.attr('id')+"_container").append("<li><a href='javascript:void(0)'>"+options.data[item][1]+"</a></li>");

                }

                return;

            }

            for(var itemLabel in options.tabs){    

                index++;           

                if(index == 1){

                    popContainer.append("<ul id='label_"+input.attr('id')+index+"_container' class='current' data-type='"+itemLabel+"'></ul>");

                    labelMain.append("<li><a id='label_"+input.attr('id')+index+"' class='current' href='javascript:void(0)'>"+itemLabel+"</a></li>");     

                }else{

                    popContainer.append("<ul style='display:none' id='label_"+input.attr('id')+index+"_container' data-type='"+itemLabel+"'></ul>");

                    labelMain.append("<li><a id='label_"+input.attr('id')+index+"' href='javascript:void(0)'>"+itemLabel+"</a></li>");     

                }

                for(var item in options.tabs[itemLabel]){

                    var cityCode = options.tabs[itemLabel][item];

                    if(!options.data[cityCode]){

                        break;

                    }              

                    $("#label_"+input.attr('id')+index+"_container").append("<li><a href='javascript:void(0)'>"+options.data[cityCode][1]+"</a></li>");

                }

            }          

        }

        function resetPosition(){

            popMain.css({'top':input.position().top+input.outerHeight()+203,'left':input.position().left+192});

            suggestMain.css({'top':input.position().top+input.outerHeight()+203,'left':input.position().left+192});

        }

    }

    $.fn.querycity = function(options){

        var defaults = {

            'data'          : {},

            'tabs'          : '',

            'hotList'       : '',            

            'defaultText'   : '中文/拼音',

            'popTitleText'  : '请选择城市或输入城市名称的拼音或英文<a style=margin-left:100px;font-weight:bold;color:#FFF;font-size:20px; href=javascript:void(0); onclick=javascript:document.getElementById("pop_city_city").style.display="none";>×</a>',

            'suggestTitleText' : '输入中文/拼音或↑↓选择',

            'suggestLength' : 10,

            'pageLength'    : 0,

            'onSelect'      : ''

        };

        var options = $.extend(defaults,options);

        this.each(function(){

            new $.querycity(this,options);            

        });

        return this;

    };



})(jQuery);





(function($){

$.fn.bgIframe = $.fn.bgiframe = function(s) {

    if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {

        s = $.extend({

            top     : 'auto', // auto == .currentStyle.borderTopWidth

            left    : 'auto', // auto == .currentStyle.borderLeftWidth

            width   : 'auto', // auto == offsetWidth

            height  : 'auto', // auto == offsetHeight

            opacity : true,

            src     : 'javascript:false;'

        }, s || {});

        var prop = function(n){return n&&n.constructor==Number?n+'px':n;},

            html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+

                       'style="display:block;position:absolute;z-index:-1;'+

                           (s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+

                           'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+

                           'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+

                           'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+

                           'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+

                    '"/>';

        return this.each(function() {

            if ( $('> iframe.bgiframe', this).length == 0 )

                //this.insertBefore( document.createElement(html), this.firstChild );

                this.insertBefore( createElementByHtml(html), this.firstChild );

        });

    }

    return this;

};



function createElementByHtml(htmlStr) {

    //如果只是根据标签名称(tagName)来创建元素,直接就好

    if (htmlStr.indexOf("<") == -1) {

        return document.createElement(htmlStr);

    }

    var $obj = $(htmlStr);

    return $obj.get(0);

}



})(jQuery);

tmp.html

下面的代码放在HTML页面里面,一定要引入Jquery的库!切记!!

1
2
3
4
5
6
7
8
9
10
11
12
13
//放在jquery里面.

 var labelFromcity = new Array();
    labelFromcity ['热门城市'] = new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40);
    labelFromcity ['A-F'] = new Array(0,3,4,5,6,28,29,93,94,95,96,97,98,99,100,101,102,103,104,105,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,148,149,150,151,152,153,154,155,156,157,158,159,160,161,164,165,166,169,170,171,172,173,174,175);
    labelFromcity ['G-J'] = new Array(1,7,8,9,30,31,32,33,37,40,178,179,180,181,182,183,184,185,186,187,188,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248);
    labelFromcity ['K-N'] = new Array(10,11,12,34,35,38,251,252,253,254,255,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,288,289,290,291,292,293,296,297,298,299,300,301,302,303,304,305,306,307);
    labelFromcity ['P-W'] = new Array(13,14,15,16,17,18,22,24,25,36,310,311,312,313,314,315,316,319,320,321,322,323,324,325,326,327,328,329,330,331,334,335,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405);
    labelFromcity ['X-Z'] = new Array(2,19,20,21,26,27,39,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480);
    //labelFromcity ['国际城市'] = new Array(41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,60,61,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93);
    var hotList = new Array(0,1,2,3,4,5,6);

$(".choosesetout").querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});//.choosesetout修改成你自己的元素类名.