Debian Codegraph @

demos/autocomplete/remote.html

raw
1 <!doctype html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>jQuery UI Autocomplete - Remote datasource</title>
7 <link rel="stylesheet" href="../../themes/base/all.css">
8 <link rel="stylesheet" href="../demos.css">
9 <style>
10 .ui-autocomplete-loading {
11 background: white url("images/ui-anim_basic_16x16.gif") right center no-repeat;
12 }
13 </style>
14 <script src="../../external/requirejs/require.js"></script>
15 <script src="../bootstrap.js">
16 function log( message ) {
17 $( "<div>" ).text( message ).prependTo( "#log" );
18 $( "#log" ).scrollTop( 0 );
19 }
20
21 $( "#birds" ).autocomplete({
22 source: "search.php",
23 minLength: 2,
24 select: function( event, ui ) {
25 log( "Selected: " + ui.item.value + " aka " + ui.item.id );
26 }
27 });
28 </script>
29 </head>
30 <body>
31
32 <div class="ui-widget">
33 <label for="birds">Birds: </label>
34 <input id="birds">
35 </div>
36
37 <div class="ui-widget" style="margin-top:2em; font-family:Arial">
38 Result:
39 <div id="log" style="height: 200px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
40 </div>
41
42 <div class="demo-description">
43 <p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are bird names, displayed when at least two characters are entered into the field.</p>
44 <p>The datasource is a server-side script which returns JSON data, specified via a simple URL for the source-option. In addition, the minLength-option is set to 2 to avoid queries that would return too many results and the select-event is used to display some feedback.</p>
45 </div>
46 </body>
47 </html>