forked from sutara79/jquery.ajax-combobox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1427 lines (1390 loc) · 48 KB
/
index.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 charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>jquery.ajax-combobox</title>
<link rel="stylesheet" href="//cdn.jsdelivr.net/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet" href="dist/jquery.ajax-combobox.css">
<link rel="stylesheet" href="sample/sample.css">
<script src="//cdn.jsdelivr.net/jquery/1.11.3/jquery.min.js"></script>
<script src="dist/jquery.ajax-combobox.js"></script><!-- required -->
<script src="sample/jquery.simple-scroll-follow.js"></script>
<script src="sample/sample.js"></script>
</head>
<body>
<header class="jumbotron">
<div class="container">
<h1>jquery.ajax-combobox</h1>
<p class="lang_en">
create a text box it can auto-complete and pull-down-select.
</p>
<p class="lang_ja">
オートコンプリートとドロップダウンリストを組み合わせたコンボボックス
</p>
<dl class="dl-horizontal">
<dt>Version</dt><dd>7.4.4</dd>
<dt>Update</dt><dd>2015-06-28</dd>
<dt>Author</dt><dd>Yuusaku Miyazaki</dd>
<dt>License</dt><dd><a href="//opensource.org/licenses/mit-license.php">MIT License</a></dd>
</dl>
<a href="//github.com/sutara79/jquery.ajax-combobox" class="btn btn-primary" role="button">GitHub »</a>
</div>
</header>
<div class="container">
<div id="contents" class="row">
<nav id="index">
<div id="language" class="btn-group">
<button id="lang_en" class="btn btn-default">English</button>
<button id="lang_ja" class="btn btn-default">Japanese</button>
</div>
<h3>
<span class="lang_en">Index</span>
<span class="lang_ja">目次</span>
</h3>
<h4>
<span class="lang_en">Basic</span>
<span class="lang_ja">基本</span>
</h4>
<div class="list-group">
<a class="list-group-item" href="#sample01_01">
<span class="lang_en">Usage</span>
<span class="lang_ja">使い方</span>
</a>
<a class="list-group-item" href="#sample01_02">
<span class="lang_en">Changing the amount of displays of the list</span>
<span class="lang_ja">候補リスト・隣接ページの表示数を変更</span>
</a>
<a class="list-group-item" href="#sample01_03">
<span class="lang_en">Simple Page-navi</span>
<span class="lang_ja">ページナビをシンプルに</span>
</a>
<a class="list-group-item" href="#sample01_04">
<span class="lang_en">Search for several fields</span>
<span class="lang_ja">複数のフィールドから検索</span>
</a>
<a class="list-group-item" href="#sample01_05">
<span class="lang_en">Change from "AND" to "OR"</span>
<span class="lang_ja">OR検索へ切り替える</span>
</a>
<a class="list-group-item" href="#sample01_06">
<span class="lang_en">Setting the rule of order</span>
<span class="lang_ja">並べ替えの規則を決める</span>
</a>
<a class="list-group-item" href="#sample01_07">
<span class="lang_en">Changing the language of the message</span>
<span class="lang_ja">メッセージの言語を変える</span>
</a>
</div>
<h4>
<span class="lang_en">Display Sub-info</span>
<span class="lang_ja">サブ情報を表示</span>
</h4>
<div class="list-group">
<a class="list-group-item" href="#sample02_01">
<span class="lang_en">Basic of Sub-info</span>
<span class="lang_ja">サブ情報の基本</span>
</a>
<a class="list-group-item" href="#sample02_02">
<span class="lang_en">Change the field name of Sub-info</span>
<span class="lang_ja">表の項目名を変更する</span>
</a>
<a class="list-group-item" href="#sample02_03">
<span class="lang_en">Setting of display field of Sub-info</span>
<span class="lang_ja">サブ情報の表示カラムの設定</span>
</a>
<a class="list-group-item" href="#sample02_04">
<span class="lang_en">Setting of hidden field of Sub-info</span>
<span class="lang_ja">サブ情報の非表示カラムの設定</span>
</a>
<a class="list-group-item" href="#sample02_05">
<span class="lang_en">Hide the field name of Sub-info</span>
<span class="lang_ja">サブ情報の項目名を非表示にする</span>
</a>
<a class="list-group-item" href="#sample02_06">
<span class="lang_en">How to use Sub-info for other purpose</span>
<span class="lang_ja">サブ情報を他で利用する</span>
</a>
</div>
<h4>
<span class="lang_en">Select-only</span>
<span class="lang_ja">セレクト専用</span>
</h4>
<div class="list-group">
<a class="list-group-item" href="#sample03_01">
<span class="lang_en">Basic of Select-only</span>
<span class="lang_ja">セレクト専用の基本</span>
</a>
<a class="list-group-item" href="#sample03_02">
<span class="lang_en">Setting of Primary key</span>
<span class="lang_ja">送信する値のカラムを変更</span>
</a>
</div>
<h4>
<span class="lang_en">After selected</span>
<span class="lang_ja">候補選択と同時に、別のイベントを発火する</span>
</h4>
<div class="list-group">
<a class="list-group-item" href="#sample06_01">
<span class="lang_en">Basic of after selected</span>
<span class="lang_ja">イベント発火の方法</span>
</a>
<a class="list-group-item" href="#sample06_02">
<span class="lang_en">Not enclosed by "form" tag</span>
<span class="lang_ja">formタグで囲んでいない場合</span>
</a>
</div>
<h4>
<span class="lang_en">Others</span>
<span class="lang_ja">その他</span>
</h4>
<div class="list-group">
<a class="list-group-item" href="#sample04_01">
<span class="lang_en">Initial value</span>
<span class="lang_ja">初期値設定</span>
</a>
<a class="list-group-item" href="#sample05_01">
<span class="lang_en">Search for JSON without database</span>
<span class="lang_ja">データベースではなく、JSON形式のデータを検索する</span>
</a>
<a class="list-group-item" href="#sample07_01">
<span class="lang_en">Simple textbox</span>
<span class="lang_ja">ボタンのないシンプルなテキストボックス</span>
</a>
<a class="list-group-item" href="#sample07_02">
<span class="lang_en">Getting plugin object</span>
<span class="lang_ja">プラグインのオブジェクトを受け取る</span>
</a>
</div>
<h4>
<span class="lang_en">Textarea (tag and shorten url)</span>
<span class="lang_ja">テキストエリア (タグ検索とURL短縮)</span>
</h4>
<div class="list-group">
<a class="list-group-item" href="#sample08_01">
<span class="lang_en">Basic of textarea</span>
<span class="lang_ja">テキストエリアの基本</span>
</a>
<a class="list-group-item" href="#sample08_02">
<span class="lang_en">Do not insert space</span>
<span class="lang_ja">タグ補完後に空白を挿入しない</span>
</a>
<a class="list-group-item" href="#sample08_03">
<span class="lang_en">Search for JSON without database</span>
<span class="lang_ja">データベースではなく、JSON形式のデータを検索する</span>
</a>
<a class="list-group-item" href="#sample08_04">
<span class="lang_en">Several patterns of tags</span>
<span class="lang_ja">複数のタグパターン</span>
</a>
<a class="list-group-item" href="#sample08_05">
<span class="lang_en">Set options for every tags</span>
<span class="lang_ja">タグごとにオプションを設定する</span>
</a>
<a class="list-group-item" href="#sample08_06">
<span class="lang_en">Shorten URL</span>
<span class="lang_ja">URLを短縮する</span>
</a>
<a class="list-group-item" href="#sample08_07">
<span class="lang_en">Using both</span>
<span class="lang_ja">両方を使う</span>
</a>
</div>
</nav>
<article>
<section id="sample01_01" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Usage</span>
<span class="lang_ja">使い方</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
First parameter => File name transmitted by Ajax<br>
Second parameter => Options
</p>
<p class="lang_ja">
第1引数にAjax送信先のファイル名を、<br>
第2引数にオプションを設定します。
</p>
<label for="ac01_01">
<span class="lang_en">Nation:</span>
<span class="lang_ja">国名:</span>
</label>
<input id="ac01_01" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac01_01')">
<h6>HTML</h6>
<pre>
<input id="ac01_01" type="text">
</pre>
<h6>JavaScript</h6>
<pre>
$('#ac01_01').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
<span class="green">lang: 'en',</span>
db_table: 'nation'
}
);
</pre>
<a class="btn btn-success" href="sample/basic/" target="_blank">Sample » (new window)</a>
</div>
</section>
<section id="sample01_02" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Changing the amount of displays of the list</span>
<span class="lang_ja">候補リスト・隣接ページの表示数を変更</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
"per_page" option => The number of displays of lists is changed.<br>
"navi_num" option => The number of page is changed.
</p>
<p class="lang_ja">
"per_page"オプションで、候補リストの表示数を、<br>
"navi_num"オプションで、隣接ページの表示数を変更できます。
</p>
<label for="ac01_02">
<span class="lang_en">Name:</span>
<span class="lang_ja">人名:</span>
</label>
<input id="ac01_02" type="text" style="width:400px">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac01_02')">
<h6>JavaScript</h6>
<pre>
$('#ac01_02').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
lang: 'en',
db_table: 'name',
<span class="green">per_page: 20,</span>
<span class="green">navi_num: 10,</span>
}
);
</pre>
</div>
</section>
<section id="sample01_03" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Simple Page-navi</span>
<span class="lang_ja">ページナビをシンプルに</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
Please set "navi_simple" option when you want to narrow<br>
the width of the ComboBox as much as possible.
</p>
<p class="lang_ja">
ComBoxの幅をできるだけ狭くしたい場合、"navi_simple"オプションで<br>
先頭・末尾のページへのリンクを非表示にできます。<br>
なお、キーボードのショートカットは有効のままです。(Shift + 右・左)
</p>
<label for="ac01_03">
<span class="lang_en">Name:</span>
<span class="lang_ja">人名:</span>
</label>
<input id="ac01_03" type="text" style="width:160px">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac01_03')">
<h6>JavaScript</h6>
<pre>
$('#ac01_03').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
lang: 'en',
db_table: 'name',
navi_num: 1,
<span class="green">navi_simple: true</span>
}
);
</pre>
</div>
</section>
<section id="sample01_04" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Search for several fields</span>
<span class="lang_ja">複数のフィールドから検索</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
Set several fields for "search_field" option.<br>
Please input "23" to the following box.
</p>
<p class="lang_ja">
カンマ区切りでフィールド名を指定することで、<br>
同じテーブルの中の複数のフィールドから検索できます。<br>
試しに、下のボックスに『23』と入力してみてください。
</p>
<label for="ac01_04">
<span class="lang_en">Nation (name, id):</span>
<span class="lang_ja">国名 (name, id):</span>
</label>
<input id="ac01_04" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac01_04')">
<h6>JavaScript</h6>
<pre>
$('#ac01_04').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
lang : 'en',
db_table : 'nation',
<span class="green">search_field: 'name, id'</span>
}
);
</pre>
</div>
</section>
<section id="sample01_05" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Change from "AND" to "OR"</span>
<span class="lang_ja">OR検索へ切り替える</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
You can change the type of search from "AND" to "OR".<br>
Please input "ame ja" to the following box.
</p>
<p class="lang_ja">
スペース区切りで複数の言葉で検索した場合、<br>
デフォルトではAND検索となりますが、OR検索にすることもできます。<br>
試しに、下のボックスに『ame ja』と入力してみてください。
</p>
<label for="ac01_05">
<span class="lang_en">Nation:</span>
<span class="lang_ja">国名:</span>
</label>
<input id="ac01_05" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac01_05')">
<h6>JavaScript</h6>
<pre>
$('#ac01_05').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
lang: 'en',
db_table: 'nation',
<span class="green">and_or: 'OR'</span>
}
);
</pre>
</div>
</section>
<section id="sample01_06" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Setting the rule of order</span>
<span class="lang_ja">並べ替えの規則を決める</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
Basically, it is arranged by "search_field" option.<br>
You can also arrange it by "order_by" option.
</p>
<p class="lang_ja">
基本的には、"search_field"オプションに指定されたフィールドの昇順に並べ替えられます。<br>
"order_by"オプションで任意に指定することもできます。
</p>
<label for="ac01_06">
<span class="lang_en">Nation:</span>
<span class="lang_ja">国名:</span>
</label>
<input id="ac01_06" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac01_06')">
<h6>JavaScript</h6>
<pre>
$('#ac01_06').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
lang: 'en',
db_table: 'nation',
field: 'name',
order_by: [
'name DESC',
'created'
]
}
);
</pre>
<pre>
<span class="green">(field-name)</span>
order_by: 'name'
<span class="green">(field-name + ASC/DESC)</span>
order_by: 'name DESC'
<span class="green">(Array)</span>
order_by: [
'name DESC',
'id'
]
</pre>
</div>
</section>
<section id="sample01_07" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Changing the language of the message</span>
<span class="lang_ja">メッセージの言語を変える</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
Set the <code>lang</code> option.
</p>
<p class="lang_ja">
<code>lang</code>オプションで指定してください。
</p>
<table class="table">
<thead><tr><th>Option value</th><th>Language</th></tr></thead>
<tbody>
<tr><td>de</td><td>German<br>(Thanks Sebastian Gohres)</td></tr>
<tr><td>en</td><td>English</td></tr>
<tr><td>es</td><td>Spanish<br>(Thanks Joaquin G. de la Zerda)</td></tr>
<tr><td>pt-br</td><td>Brazilian Portuguese<br>(Thanks Marcio de Souza)</td></tr>
<tr><td>ja (default)</td><td>Japanese</td></tr>
</tbody>
</table>
<label for="ac01_07_01">
<span class="lang_en">Nation (de):</span>
<span class="lang_ja">国名 (de):</span>
</label>
<input id="ac01_07_01" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac01_07_01')">
<hr>
<label for="ac01_07_02">
<span class="lang_en">Nation (es):</span>
<span class="lang_ja">国名 (es):</span>
</label>
<input id="ac01_07_02" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac01_07_02')">
<hr>
<label for="ac01_07_03">
<span class="lang_en">Nation (pt-br):</span>
<span class="lang_ja">国名 (pt-br):</span>
</label>
<input id="ac01_07_03" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac01_07_03')">
<hr>
<label for="ac01_07_04">
<span class="lang_en">Nation (ja):</span>
<span class="lang_ja">国名 (ja):</span>
</label>
<input id="ac01_07_04" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac01_07_04')">
</section>
<section id="sample02_01" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Basic of Sub-info</span>
<span class="lang_ja">サブ情報の基本</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
Each candidate can be distinguished when there is a candidate of the same name.
</p>
<p class="lang_ja">
同一名の候補がある場合、右側にサブ情報を表示させて<br>
それぞれを区別することができます。
</p>
<label for="ac02_01">
<span class="lang_en">Employee:</span>
<span class="lang_ja">社員名:</span>
</label>
<input id="ac02_01" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac02_01')">
<h6>JavaScript</h6>
<pre>
$('#ac02_01').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
lang: 'en',
db_table: 'employee',
<span class="green">sub_info: true</span>
}
);
</pre>
</div>
</section>
<section id="sample02_02" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Change the field name of Sub-info</span>
<span class="lang_ja">表の項目名を変更する</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
"sub_as" option can change the field-name.
</p>
<p class="lang_ja">
何も設定しないと、サブ情報の表の項目名は、データベースの<br>
カラム名が表示されてしまいます。<br>
"sub_as"オプションで、表示名を変更できます。
</p>
<label for="ac02_02">
<span class="lang_en">Employee:</span>
<span class="lang_ja">社員名:</span>
</label>
<input id="ac02_02" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac02_02')">
<h6>JavaScript</h6>
<pre>
$('#ac02_02').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
lang: 'en',
db_table: 'employee',
sub_info: true,
<span class="green">sub_as: {</span>
<span class="green">id: 'Employer ID',</span>
<span class="green">post: 'Post',</span>
<span class="green">position: 'Position'</span>
<span class="green">}</span>
}
);
</code>
</div>
</section>
<section id="sample02_03" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Setting of display field of Sub-info</span>
<span class="lang_ja">サブ情報の表示カラムの設定</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
"show_field" option choose the displayed field-name.
</p>
<p class="lang_ja">
"show_field"オプションで設定します。<br>
カンマ区切りで、複数のカラム名を指定します。<br>
オプションでの記述の順番でカラムを取得します。
</p>
<label for="ac02_03">
<span class="lang_en">Employee:</span>
<span class="lang_ja">社員名:</span>
</label>
<input id="ac02_03" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac02_03')">
<h6>JavaScript</h6>
<pre>
$('#ac02_03').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
lang: 'en',
db_table: 'employee',
sub_info: true,
sub_as: {
post: 'Post',
position: 'Position'
},
<span class="green">show_field: 'position, post'</span>
}
);
</code>
</div>
</section>
<section id="sample02_04" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Setting of hidden field of Sub-info</span>
<span class="lang_ja">サブ情報の非表示カラムの設定</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
"hide_field" option choose the hidden field-name.
</p>
<p class="lang_ja">
"hide_field"オプションで設定します。<br>
複数のカラムを取得する場合の記述のルールは<br>
"show_field"オプションと同じです。
</p>
<label for="ac02_04">
<span class="lang_en">Employee:</span>
<span class="lang_ja">社員名:</span>
</label>
<input id="ac02_04" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac02_04')">
<h6>JavaScript</h6>
<pre>
$('#ac02_04').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
lang: 'en',
db_table: 'employee',
sub_info: true,
sub_as: {
id: 'Employer ID'
},
<span class="green">hide_field: 'position,post'</span>
}
);
</pre>
</div>
</section>
<section id="sample02_05" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Hide the field name of Sub-info</span>
<span class="lang_ja">サブ情報の項目名を非表示にする</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
Set "simple" to "sub_info" option instead of "true".
</p>
<p class="lang_ja">
"sub_info"オプションに"true"の代わりに"simple"と指定することで、<br>
サブ情報の項目名を非表示にできます。
</p>
<label for="ac02_05">
<span class="lang_en">Employee:</span>
<span class="lang_ja">社員名:</span>
</label>
<input id="ac02_05" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac02_05')">
<h6>JavaScript</h6>
<pre>
$('#ac02_05').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
lang: 'en',
db_table: 'employee',
<span class="green">sub_info</span>: <span class="red">'simple'</span>,
show_field: 'post'
}
);
</code>
</div>
</section>
<section id="sample02_06" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">How to use Sub-info for other purpose</span>
<span class="lang_ja">サブ情報を他で利用する</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
The "sub_info" attribute is added to text box<br>
when you select from list.<br>
So, you can use Sub-info for other purpose.
</p>
<p class="lang_ja">
候補を選択した際、<br>
テキストボックスの『sub_info』という独自の属性に<br>
JSON形式でサブ情報が格納されるので、他で利用することが可能です。
</p>
<label for="ac02_06">
<span class="lang_en">Employee:</span>
<span class="lang_ja">社員名:</span>
</label>
<input id="ac02_06" type="text">
<input class="check_btn" type="button" value="Check Sub-info" onclick="func_02_06()">
<script>
function func_02_06() {
var result = 'Sub-info\n';
var json = $('#ac02_06').attr('sub_info');
var obj = eval( '(' + json + ')' );
for(var key in obj) {
result += key + ' : ' + obj[key] + '\n';
}
alert(result);
}
</script>
<h6>JavaScript</h6>
<pre>
var result = 'Sub-info\n';
var json = $('#ac_02_06')<span class="green">.attr('sub_info')</span>;
var obj = <span class="green">eval( '(' + json + ')' )</span>;
for(var key in obj) {
result += key + ' : ' + obj[key] + '\n';
}
alert(result);
</pre>
</div>
</section>
<section id="sample03_01" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Basic of Select-only</span>
<span class="lang_ja">セレクト専用の基本</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
When the value that does not exist in the list is input, warning is received.
</p>
<p class="lang_ja">
候補を選択した際、<br>
テキストボックスの『sub_info』という独自の属性に<br>
JSON形式でサブ情報が格納されるので、他で利用することが可能です。
</p>
<label for="ac03_01">
<span class="lang_en">Employee:</span>
<span class="lang_ja">社員名:</span>
</label>
<input id="ac03_01" name="ac03_01" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac03_01')">
<h6>JavaScript</h6>
<pre>
$('#ac03_01').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
lang: 'en',
db_table: 'employee',
sub_info: true,
<span class="green">select_only: true</span>
}
);
</pre>
<p class="lang_en">
If this option is set, the value of "Primary_key" field transmit by the form.
</p>
<p class="lang_ja">
なお、このオプションを設定すると、フォームで送信されるのは<br>
"primary_key"オプションで設定したカラムの値になります。
この値は、候補リストの<li>要素のid属性にもなります。<br><br>
テキストボックスと同じname属性を持つ隠しフィールド(hidden)を<br>
生成し、リストから選択した場合のみ、"primary_key"の値を<br>
hiddenのvalue属性に設定しています。
</p>
<pre>
<span class="gray">// Textbox</span>
<input id="ac03_01_1" name="<span class="green">ac03_01_1</span>" type="text" />
<span class="gray">// List</span>
...
<li id="A010" class="">Adams</li>
<li id="<span class="red">A009</span>" class="ac_over">Adams</li>
<li id="A005" class="">Adams</li>
...
<span class="gray">// Hidden field</span>
<input type="hidden" name="<span class="green">ac03_01_1</span>" value="<span class="red">A011</span>"/>
</pre>
</div>
</section>
<section id="sample03_02" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Setting of Primary key</span>
<span class="lang_ja">送信する値のカラムを変更</span>
</h3>
</div>
<div class="panel-body">
<label for="ac03_02">
<span class="lang_en">Nation:</span>
<span class="lang_ja">国名:</span>
</label>
<input id="ac03_02" name="ac03_02" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac03_02')">
<pre>
$('#ac03_02').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
lang: 'en',
db_table: 'nation',
show_field: 'id',
sub_info: true,
select_only: true,
<span class="green">primary_key: 'name'</span>
}
);
</pre>
</div>
</section>
<section id="sample06_01" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Basic of after selected</span>
<span class="lang_ja">イベント発火の方法</span>
</h3>
</div>
<div class="panel-body">
<label for="ac06_01">
<span class="lang_en">Nation:</span>
<span class="lang_ja">国名:</span>
</label>
<input id="ac06_01" type="text">
<h6>JavaScript</h6>
<pre>
$('#ac06_01').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
db_table: 'nation',
<span class="green">bind_to</span>: <span class="red">'foo'</span>
}
)
.bind(<span class="red">'foo'</span>, function() {
alert($(this).val() + ' is selected.');
});
</pre>
</div>
</section>
<section id="sample06_02" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Not enclosed by "form" tag</span>
<span class="lang_ja">formタグで囲んでいない場合</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
If text box is not enclosed by form tag and event handler is set<br>
for inputting enter key, when one of the list is selected by enter key<br>
function is doubly executed.<br>
To avoid this situation, a argument that become true when selected by<br>
enter key is set When originality event of plugin is fired.
</p>
<p class="lang_ja">
テキストボックスをフォームタグで囲まず、Enterキーが押された場合の<br>
イベントハンドラを独自に用意している場合、候補をEnterキーで選ぶと<br>
イベントが重複して実行されてしまいます。<br>
それを防ぐため、プラグインの独自イベントが発火する際に、<br>
Enterキーで候補が選ばれた場合はtrueとなる引数を追加しました。
</p>
<label for="ac06_02">
<span class="lang_en">Nation:</span>
<span class="lang_ja">国名:</span>
</label>
<input id="ac06_02" type="text">
<h6>JavaScript</h6>
<pre>
$('#ac06_02').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
db_table: 'nation',
bind_to: 'foo'
}
)
.bind('foo', function(e, <span class="green">is_enter_key</span>) {
if(<span class="green">!is_enter_key</span>) {
alert($(this).val() + ' is selected. (by mouse)');
}
})
.keydown(function(e){
if(e.keyCode == 13) alert($(this).val() + ' is selected. (by enter key)');
});
</pre>
</div>
</section>
<section id="sample04_01" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Initial value</span>
<span class="lang_ja">初期値設定</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
<span class="underline bold">NOTE: please set the value of the primary key of database.</span>
</p>
<p class="lang_ja">
ComboBoxに初期値を設定します。<br>
<span class="underline bold">初期値は、'primary_key'オプションのDBカラムの値を指定して下さい。</span>
</p>
<label for="ac04_01">
<span class="lang_en">Nation:</span>
<span class="lang_ja">国名:</span>
</label>
<input id="ac04_01" name="ac04_01" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac04_01')">
<h6>JavaScript</h6>
<pre>
$('#ac04_01').ajaxComboBox(
'dist/jquery.ajax-combobox.php',
{
lang : 'en',
db_table : 'nation',
<span class="green">init_record : </span><span class="red">28</span>
}
);
</pre>
</div>
</section>
<section id="sample05_01" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Search for JSON without database</span>
<span class="lang_ja">データベースではなく、JSON形式のデータを検索する</span>
</h3>
</div>
<div class="panel-body">
<p class="lang_en">
Search from JSON without database or server-side like PHP.
</p>
<p class="lang_ja">
データベースもサーバサイド言語も使わず、JSON形式のデータを検索します。<br>
JSON形式のデータは、下記のようなオブジェクト配列にする必要があります。
</p>
<h6>JavaScript</h6>
<pre>
var data = [
{id:'A001',name:'Adams',post:'Sales',position:'The rank and file'},
{id:'A002',name:'Darling',post:'Sales',position:'The rank and file'},
{id:'A003',name:'Kingston',post:'General Affairs',position:'Chief clerk'},
{id:'A004',name:'Darling',post:'General Affairs',position:'Section chief'},
...
];
</pre>
<p class="lang_en">
Set JSON object instead of a name of server-side file.
</p>
<p class="lang_ja">
Ajax通信するサーバサイドのファイル名の代わりに、<br>
JSON形式のオブジェクト配列を指定します。
</p>
<label for="ac05_01">
<span class="lang_en">Employee:</span>
<span class="lang_ja">社員名:</span>
</label>
<input id="ac05_01" name="ac05_01" type="text">
<input class="check_btn" type="button" value="Check the value." onclick="displayResult('ac05_01')">
<h6>JavaScript</h6>
<pre>
$('#ac05_01').ajaxComboBox(
<span class="green">data</span>,
{
sub_info: true,
sub_as: {
id: 'Employer ID',
post: 'Post',
position: 'Position'
},
select_only: true,
init_record: ['A009'],
primary_key: 'id'
}
);
</pre>
</div>
</section>
<section id="sample07_01" class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<span class="lang_en">Simple textbox</span>