This repository has been archived by the owner on Aug 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
index_en.html
1162 lines (1027 loc) · 31.2 KB
/
index_en.html
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
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LinkageSel: Infinite Level Linkage Select</title>
<link type="text/css" rel="stylesheet" href="css/common.css" />
<link type="text/css" rel="stylesheet" href="js/syntaxhighlighter/shCore.css" />
<link rel="stylesheet" type="text/css" href="js/syntaxhighlighter/shThemeDefault.css" />
<script src="js/jquery.js"></script>
</head>
<body>
<div style="position: absolute; top: 10px; right: 11px;"><a href="index.html">中文</a> | <a href="index_en.html">English</a> </div>
<div id="header"><h1>Javascript Infinite Level Linkage Select </h1></div>
<div class="main">
<h2>Overview</h2>
<ul>
<li>Multi level linkage, support ajax request and data cache, dynamic <select>construct, self defined tips as the first<option>,
the only one <option>selected automatically, self defined callback function when onChange event triggered.
</li>
</ul>
<h2>Requirement</h2>
<ul>
<li>jQuery v1.6+</li>
</ul>
<h2>License</h2>
<ul>
<li>
Dual licensed under the MIT and GPL licenses: <br>
<a href="http://www.opensource.org/licenses/mit-license.php">http://www.opensource.org/licenses/mit-license.php</a> <br>
<a href="http://www.gnu.org/licenses/gpl.html">http://www.gnu.org/licenses/gpl.html</a>
</ul>
<h2>Author</h2>
<ul>
<li><a target="_blank" href="http://linkagesel.xiaozhong.biz">waiting AT xiaozhong.biz</a></li>
</ul>
<h2>Update</h2>
<ul>
<li>See <a href="changes_en.txt" >changes</a></li>
</ul>
<h2>Download</h2>
<ul>
<li>
<a target="_blank" href="http://linkagesel.xiaozhong.biz/linkagesel.zip">linkagesel.zip</a> including chinese-district data
of js and postgres
</li>
<li>
<a target="_blank" href="https://github.com/waitingsong/LinkageSel">GitHub Repository</a>
</li>
</ul>
<h2>Settings</h2>
<ul>
<li>
Usage:
var linkageSel = new LinkageSel(opts);
</li>
<li>opts params:
<table width="90%" border="1" cellspacing="0" cellpadding="5" style="margin-top:10px" >
<tr>
<td width="12%" align="center">param name</td>
<td width="10%" align="center">type</td>
<td width="22%" align="center">default value</td>
<td width="4%" align="center">optional</td>
<td width="" align="center">comment</td>
</tr>
<tr>
<td>data</td>
<td>Object</td>
<td>null</td>
<td>√</td>
<td>local js data. can be used with 'ajax' param</td>
</tr>
<tr>
<td>url</td>
<td>String</td>
<td> </td>
<td>√</td>
<td>remote url address, get all data at one time</td>
</tr>
<tr>
<td>ajax</td>
<td>String</td>
<td> </td>
<td>√</td>
<td>remote url address for ajax</td>
</tr>
<tr>
<td>autoBind</td>
<td>Boolean</td>
<td>true</td>
<td>√</td>
<td>whether constrct next level <select> automatically</td>
</tr>
<tr>
<td>autoHide</td>
<td>Boolean</td>
<td>true</td>
<td>√</td>
<td>whether hide next levevl <select> which has not items</td>
</tr>
<tr>
<td>hideWidth</td>
<td>Boolean</td>
<td>true</td>
<td>√</td>
<td>whether release the postion width if set 'autoHide' to TRUE. (true->'display:none'||false-> 'visibility:hidden')</td>
</tr>
<tr>
<td>autoLink</td>
<td>Boolean</td>
<td>true</td>
<td>√</td>
<td>whether linkage to next level if only one item exists</td>
</tr>
<tr>
<td>defVal</td>
<td>Integer|Array</td>
<td>true</td>
<td>√</td>
<td>default selected value. integer for first <select>, array for multi <select> </td>
</tr>
<tr>
<td>head</td>
<td>String|Number|false</td>
<td>Please select..</td>
<td>√</td>
<td>the first <option> name. blank string ('') is valid</td>
</tr>
<tr>
<td>level</td>
<td>Integer</td>
<td>20</td>
<td>√</td>
<td>limit to avoid Infinite loop</td>
</tr>
<tr>
<td>loaderImg</td>
<td>String</td>
<td>images/ui-anim_basic_16x16.gif</td>
<td>√</td>
<td>ajax loader image</td>
</tr>
<tr>
<td>root</td>
<td>Integer|Array</td>
<td> </td>
<td>√</td>
<td>root entry. invalid for ajax request</td>
</tr>
<tr>
<td>select</td>
<td>String|Array</td>
<td> </td>
<td></td>
<td>jQuery selector of array of selector</td>
</tr>
<tr>
<td>selClass</td>
<td>String</td>
<td> </td>
<td>√</td>
<td>class name for <select> which is constructed by code</td>
</tr>
<tr>
<td>selStyle</td>
<td>String</td>
<td> </td>
<td>√</td>
<td>css style for <select> which is constructed by code</td>
</tr>
<tr>
<td>minWidth</td>
<td>Integer</td>
<td>120</td>
<td>√</td>
<td></td>
</tr>
<tr>
<td>maxWidth</td>
<td>Integer</td>
<td>300</td>
<td>√</td>
<td></td>
</tr>
<tr>
<td>fixWidth</td>
<td>Integer</td>
<td>0</td>
<td>√</td>
<td>override effect defined by minWidth or maxWidth</td>
</tr>
<tr>
<td>onChange</td>
<td>Function</td>
<td> </td>
<td>√</td>
<td>callback function when onChange event fired</td>
</tr>
<tr>
<td>mvcQuery</td>
<td>Boolean</td>
<td>false</td>
<td>√</td>
<td>ajax request url compatible to MVC when set to true,
eg. http://linkagesel.xiaozhong.biz/district/get_nodes/1 when 'ajax' set to 'district/get_nodes'
</td>
</tr>
<tr>
<td>dataReader</td>
<td>Object</td>
<td>{id: 'id', name: 'name', cell: 'cell'}</td>
<td>√</td>
<td>You can define othe data key name , such as {id: 'gid', name: 'value', cell: 'subcell'} </td>
</tr>
</table>
</li>
<li>
Method:
<table width="90%" border="1" cellspacing="0" cellpadding="5" style="margin-top:10px" >
<thead>
<td width="15%" align="center">method name</td>
<td width="20%" align="center">param and type</td>
<td width="8%" align="center">type of return</td>
<td width="8%" align="center">chainable</td>
<td width="" align="center">comment</td>
</thead>
<tr>
<td>changeValues</td>
<td>param1:Integer|Array <br /> param2: Boolean[option=false] </td>
<td>Object</td>
<td>√</td>
<td>change option value by hand. param2 to determine fire callback funcion bind on onChange event or not</td>
</tr>
<tr>
<td>getSelectedValue</td>
<td>idx:Integer</td>
<td>String</td>
<td> </td>
<td>return the value of the idx of <select> (begein from zero). the return value is from the last element if no param pass.
return null if all element no selected item.</td>
</tr>
<tr>
<td>getSelectedArr</td>
<td> </td>
<td>Array</td>
<td> </td>
<td>the return array include the value of all elements</td>
</tr>
<tr>
<td>getSelectedData</td>
<td>
key: String <br />
idx: Interger[option]
</td>
<td>Object</td>
<td> </td>
<td>get data of the selected item row. the return data will from the last elemnet which has valid selected item if pass zero to inx</td>
</tr>
<tr>
<td>getSelectedDataArr</td>
<td>key: String[option]</td>
<td>Array</td>
<td> </td>
<td>get all of the element object or object value which has selected item, stop at the one which has no seleted item.
if key is valid then return object[key] (type is int|string|null), if key not defined then return ojbect (typeis object|null)</td>
</tr>
<tr>
<td>onChange</td>
<td>callback: Function;</td>
<td> </td>
<td>√</td>
<td>callback function bind to onchange event on element.
the variable this inner the function refer to the instance of LinkageSel (See Demo2)</td>
</tr>
<tr>
<td>reset</td>
<td> </td>
<td> </td>
<td>√</td>
<td>reset to init status</td>
</tr>
<tr>
<td>resetAll</td>
<td> </td>
<td> </td>
<td>√</td>
<td>reset to init status, including defVal and data</td>
</tr>
</table>
</li>
</ul>
<h2 style="margin-top: 50px;">Demo</h2>
<div class="main">
<div class="lsdemo">
<h3><a name="demo1">Loading:</a></h3>
<pre class="brush: html">
<script src="js/jquery.js"></script>
<script src="js/comm.js"></script>
<script src="js/linkagesel-min.js"></script>
</pre>
</div>
<div class="lsdemo">
<h3><a>Data structure</a></h3>
<pre class="brush: js">
<script>
{
$id : {"name": $nameValue, "otherAttr": $otherAttrVal, "cell": { ... },
};
or
{
$id : {"id": $id, "name": $nameValue, "otherAttr": $otherAttrVal, "cell": { ... },
};
</script>
$id is sequence index, used at <option value="$id"></option> the value of the "value"
'name' is used at <optio>NAME<option>
'otherAttr' is optional other key name, such as 'price', 'zip'
'cell' is optional key name which contains sub data row
example:
var data1 = {
1: {name: 'Vegetables',
cell: {
10: {name: 'Spinach', price: 4 },
11: {name: 'Eggplant', price: 5}
}
};
or
var data1 = {
1: {id: 1, name: 'Vegetables',
cell: {
10: {id: 10, name: 'Spinach', price: 4 },
11: {id: 11, name: 'Eggplant', price: 5}
}
};
or
var data1 = {
123: {id: 1, name: 'Vegetables',
cell: {
234: {id: 10, name: 'Spinach', price: 4 },
345: {id: 11, name: 'Eggplant', price: 5}
}
};
Vegetables (id==1)
|-->Spinach (id==1, price==4)
|-->Eggplant (id==10, price==5)
</pre>
You can define the key name by yourself pass dataReader
</div>
<div class="lsdemo">
<h3>Demo1:Start simple one</h3>
<div><select id="demo1" ></select></div>
<div style="margin-top: 10px">
<input type="button" title="get value of the last valid one" value="button1" id="getSelectedValue"/> get value of the last one which has selected item <br />
<input type="button" title="" value="button2" id="getSelectedData"/> get last attribute value of the valid last
</div>
<pre class="brush: js">
<script>
$(document).ready(function(){
var data1 = {
1: {name: 'Vegetables', cell: { 10: {name: 'Spinach', price: 4 }, 11: {name: 'Eggplant', price: 5} }
},
3: {name: 'Fruit',
cell: {
20: {name: 'Apple', cell: {201: {name: 'china', price: 20} } } ,
21: {name: 'Peach',
cell: {
210: {name: 'Kiwi', price: 30},
211: {name: 'Nectarine', price: 31},
}
}
}
},
9: {name: 'Food',
cell: {
30: {name: 'Rice', cell: { 301: {name: 'USA', cell: {3001: {name: 'China', price: 50}} } } }
}
}
};
var opts = {
data: data1,
select: '#demo1'
};
var linkageSel1 = new LinkageSel(opts);
$('#getSelectedValue').click(function() {
var v = linkageSel.getSelectedValue();
alert(v);
});
$('#getSelectedData').click(function() {
var name = linkageSel.getSelectedData('name'),
price = linkageSel.getSelectedData('price');
alert('name:' + name + ' price:' + price);
});
});
</script>
</pre>
<script>
$(document).ready(function(){
var data1 = {
1: {name: 'Vegetables', cell: { 10: {name: 'Spinach', price: 4 }, 11: {name: 'Eggplant', price: 5} }
},
3: {name: 'Fruit',
cell: {
20: {name: 'Apple', cell: {201: {name: 'china', price: 20} } } ,
21: {name: 'Peach',
cell: {
210: {name: 'Kiwi', price: 30},
211: {name: 'Nectarine', price: 31},
}
}
}
},
9: {name: 'Food',
cell: {
30: {name: 'Rice', cell: { 301: {name: 'USA', cell: {3001: {name: 'China', price: 50}} } } }
}
}
};
var opts = {
data: data1,
select: '#demo1'
};
var linkageSel = new LinkageSel(opts);
$('#getSelectedValue').click(function() {
var v = linkageSel.getSelectedValue();
alert(v);
});
$('#getSelectedData').click(function() {
var name = linkageSel.getSelectedData('name'),
price = linkageSel.getSelectedData('price');
alert('name:' + name + ' price:' + price);
});
});
</script>
</div>
<div class="lsdemo">
<h3>Demo2:Chinese provience city 3 level chain, all data local, get attribute value on onChange</h3>
<div>
<select id="demo2" ></select>
</div>
<div style="margin-top: 10px">
<input type="text" value="Address" id="tip" size="50" />
</div>
<div style="margin-top: 10px">
<input type="button" title="" value="button3" id="getValueArr2"/> get the value of all <select> elements
</div>
<pre class="brush: js">
<select id="demo2"></select>
地址:<input type="text" value="tip" id="tip" size="50" />
<input type="button" value="button3" id="getValueArr2"/>
<script src="js/district-all.js"></script>
<script>
var opts = {
data: districtData, // 'districtData' is the variable name assign in district-all.js
selStyle: 'margin-left: 3px;',
select: '#demo2'
};
var linkageSel2 = new LinkageSel(opts);
districtData = opts = null;
$('#getValueArr2').click(function() {
var arr = linkageSel2.getSelectedArr();
alert(arr.join(','));
});
linkageSel2.onChange(function() {
var input = $('#tip'),
d = this.getSelectedDataArr('name'), // this refer to linkageSel2
zip = this.getSelectedData('zip'), // zip of the last elm
arr = [];
for (var i = 0, len = d.length; i < len; i++) {
arr.push(d[i]);
}
zip = zip ? ' zip:' + zip : '';
input.val(arr.join(' ') + zip);
});
</script>
</pre>
<script>
$(document).ready(function(){
var opts = {
data: districtData,
selStyle: 'margin-left: 3px;',
select: '#demo2',
dataReader: {id: 'id', name: 'name', cell: 'cell'}
};
var linkageSel2 = new LinkageSel(opts);
$('#getValueArr2').click(function() {
var arr = linkageSel2.getSelectedArr();
alert(arr.join(','));
});
linkageSel2.onChange(function() {
var input = $('#tip'),
d = this.getSelectedDataArr('name'),
zip = this.getSelectedData('zip'),
arr = [];
for (var i = 0, len = d.length; i < len; i++) {
arr.push(d[i]);
}
zip = zip ? ' zip:' + zip : '';
input.val(arr.join(' ') + zip);
});
});
</script>
</div>
<div class="lsdemo">
<h3>Demo3:Chinese provience city 3 level chain, all data from ajax request</h3>
<div>
<select id="demo3" ></select>
</div>
<pre class="brush: js">
<script>
var opts = {
ajax: 'district_crud.php?aj=15',
selStyle: 'margin-left: 3px;',
select: '#demo3'
};
var linkageSel3 = new LinkageSel(opts);
</script>
</pre>
<script>
$(document).ready(function(){
var opts = {
ajax: 'district_crud.php?aj=15',
selStyle: 'margin-left: 3px;',
select: '#demo3'
};
var linkageSel3 = new LinkageSel(opts);
});
</script>
</div>
<div class="lsdemo">
<h3>Demo4: 1st level local, others ajax get</h3>
<div>
<select id="demo4" ></select>
</div>
<pre class="brush: js">
<script>
var data4 = {2: {name: 'Beijing'}, 4:{name: 'Hebei province'} };
var opts4 = {
data: data4,
ajax: 'district_crud.php?aj=15', // ajax+local data
selStyle: 'margin-left: 3px;',
select: '#demo4'
};
new LinkageSel(opts4);
</script>
</pre>
<script>
$(document).ready(function(){
var data4 = {2: {name: 'Beijing'}, 4:{name: 'Hebei province'} };
var opts4 = {
data: data4,
ajax: 'district_crud.php?aj=15',
selStyle: 'margin-left: 3px;',
select: '#demo4'
};
new LinkageSel(opts4);
});
</script>
</div>
<div class="lsdemo">
<h3>Demo5: set default item</h3>
<div>
<select id="demo5" ></select>
</div>
<pre class="brush: js">
<script src="js/district-all.js"></script>
<script>
var opts5 = {
data: districtData,
selStyle: 'margin-left: 3px;',
select: ['#demo5'], // can be Array
defVal: [4]
};
var linkageSel5 = new LinkageSel(opts5);
</script>
</pre>
<script>
$(document).ready(function(){
var opts5 = {
data: districtData,
selStyle: 'margin-left: 3px;',
select: ['#demo5'],
defVal: 4
};
var linkageSel5 = new LinkageSel(opts5);
});
</script>
</div>
<div class="lsdemo">
<h3>Demo6: set default item, generate the 3rd element dynamically</h3>
<div>
<select id="demo61" ></select><select id="demo62" ></select>
</div>
<pre class="brush: js">
<select id="demo61"></select> <select id="demo62"></select>
<script>
var opts6 = {
data: districtData,
select: [ '#demo61', '#demo62' ], // two static
defVal: 4
};
var linkageSel6 = new LinkageSel(opts6);
</script>
</pre>
<script>
$(document).ready(function(){
var opts6 = {
data: districtData,
selStyle: 'margin-left: 3px;',
select: [ '#demo61', '#demo62'] ,
defVal: 4
};
new LinkageSel(opts6);
});
</script>
</div>
<div class="lsdemo">
<h3>Demo7:set default items by pass array</h3>
<div>
<select id="demo7" ></select>
</div>
<pre class="brush: js">
<select id="demo7"></select>
<script>
var opts7 = {
data: districtData,
selStyle: 'margin-left: 3px;',
select: '#demo7',
defVal: [5, 256] // array
};
var linkageSel7 = new LinkageSel(opts7);
</script>
</pre>
<script>
$(document).ready(function(){
var opts7 = {
data: districtData,
selStyle: 'margin-left: 3px;',
select: '#demo7' ,
defVal: [5, 256]
};
new LinkageSel(opts7);
});
</script>
</div>
<div class="lsdemo">
<h3>Demo8: define data entry</h3>
<div>
Shanxi Province: <select id="demo8" ></select>
</div>
<pre class="brush: js">
Shanxi Province: <select id="demo8"></select>
<script>
var opts8 = {
data: districtData,
root: 5, // entry
selStyle: 'margin-left: 3px;',
select: '#demo8'
};
var linkageSel8 = new LinkageSel(opts8);
</script>
</pre>
<script>
$(document).ready(function(){
var opts8 = {
data: districtData,
root: 5,
selStyle: 'margin-left: 3px;',
select: '#demo8'
};
new LinkageSel(opts8);
});
</script>
</div>
<div class="lsdemo">
<h3>Demo9: define data entry, multi default item by pass array</h3>
<div>
<div>
Shanxi Province: <select id="demo9"></select>
</div>
<pre class="brush: js">
Shanxi Province: <select id="demo9"></select>
<script>
var opts9 = {
data: districtData,
root: 5, // entry
selStyle: 'margin-left: 3px;',
select: '#demo9',
defVal: [256, 257] // two
};
var linkageSel9 = new LinkageSel(opts9);
</script>
</pre>
<script>
$(document).ready(function(){
var opts9 = {
data: districtData,
root: 5,
selStyle: 'margin-left: 3px;',
select: '#demo9' ,
defVal: [256, 257]
};
new LinkageSel(opts9);
});
</script>
</div>
<div class="lsdemo">
<h3>Demo10: set multi data entries by pass array</h3>
<div>
Shanxi Province, Taiyuan city: <select id="demo10"></select>
</div>
<pre class="brush: js">
Shanxi Province, Taiyuan city: <select id="demo10"></select>
<script>
var opts10 = {
data: districtData,
root: [5, 256], // array
selStyle: 'margin-left: 3px;',
select: '#demo9',
defVal: 257
};
var linkageSel10 = new LinkageSel(opts10);
</script>
</pre>
<script>
$(document).ready(function(){
var opts10 = {
data: districtData,
root: [5, 256],
selStyle: 'margin-left: 3px;',
select: '#demo10' ,
defVal: 257
};
new LinkageSel(opts10);
});
</script>
</div>
<div class="lsdemo">
<h3>Demo11: fixed width</h3>
<div>
<select id="demo11" ></select>
</div>
<pre class="brush: js">
<select id="demo11"></select>
<script>
var opts11 = {
data: districtData,
selStyle: 'margin-left: 3px;',
select: '#demo11',
fixWidth: 200, // fixed
head: 'Which one?' // tips
};
var linkageSel11 = new LinkageSel(opts11);
</script>
</pre>
<script type="text/javascript">
$(document).ready(function(){
var opts11 = {
data: districtData,
select: '#demo11',
fixWidth: 200,
head: 'Which one?'
};
new LinkageSel(opts11);
});
</script>
</div>
<div class="lsdemo">
<h3>Demo12: no tips</h3>
<div>
<select id="demo12" ></select>
</div>
<pre class="brush: js">
<select id="demo12"></select>
<script>
var opts12 = {
data: districtData,
select: '#demo12',
head: false // no tips
};
var linkageSel12 = new LinkageSel(opts12);
</script>
</pre>
<script>
$(document).ready(function(){
var opts12 = {
data: districtData,
selStyle: 'margin-left: 3px;',
select: '#demo12',
head: false
};
new LinkageSel(opts12);
});
</script>
</div>
<div class="lsdemo">
<h3>Demo13: get all data by ajax one time</h3>
<div>
<select id="demo13" ></select>
</div>
<pre class="brush: js">
<select id="demo13" > </select>
<script>
var opts13 = {
select: '#demo13',
url: 'exampledata.php'
};
var linkageSel13 = new LinkageSel(opts13);
</script>
</pre>
<script>
$(document).ready(function(){
var opts13 = {
selStyle: 'margin-left: 3px;',
select: '#demo13',
url: 'exampledata.php'
};
new LinkageSel(opts13);
});
</script>
</div>
<div class="lsdemo">
<h3>Demo14: 1st level local data, others ajax get</h3>
<div>
<select id="demo14" ></select>
</div>
<pre class="brush: js">
<script src="js/district-level1.js"></script>
<script>
var opts14 = {
data: districtData1, // districtData1 name assign in file district-level1.js
ajax: 'district_crud.php?aj=15',
selStyle: 'margin-left: 3px;',
select: '#demo14'
};
var linkageSel14 = new LinkageSel(opts14);
</script>
</pre>
<script>
$(document).ready(function(){
var opts14 = {
data: districtData1,
ajax: 'district_crud.php?aj=15',
selStyle: 'margin-left: 3px;',
select: '#demo14'
};
new LinkageSel(opts14);
});
</script>
</div>
<div class="lsdemo">
<h3>Demo15: change selected item </h3>
<div>
<select id="demo15" ></select>
<button type="button" onclick="javascript: ls15.changeValues([23, 2244])">changeValues</button>
</div>
<pre class="brush: js">
<body>
<button type="button" onclick="javascript: ls15.changeValues([23, 2244])">changeValues</button>
</body>
<script src="js/district-level1.js"></script>
<script>
var ls15; // must outside of ready() !
$(document).ready(function(){
var opts15 = {
data: districtData1,
ajax: 'district_crud.php?aj=15',
selStyle: 'margin-left: 3px;',
select: '#demo15'
};
window.ls15 = new LinkageSel(opts15);
});
</script>
</pre>
<script>
var ls15;
$(document).ready(function(){
var opts15 = {
data: districtData1,
ajax: 'district_crud.php?aj=15',
selStyle: 'margin-left: 3px;',
select: '#demo15'
};
ls15 = new LinkageSel(opts15);
});
</script>
</div>
<div class="lsdemo">