Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>prueba</title>
- <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
- <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
- <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
- <link rel="stylesheet" href="/resources/demos/style.css" />
- <script>
- $(function() {
- $("#tags").autocomplete({
- source : function( request , response ){
- var url = "autocomplete.php";
- $.post(url, { 'search' : request.term }, response, 'json');
- },
- select: function( event, ui ) {
- $("#tags").val(ui.item.name);
- //$('#hidden_tag').val(ui.item.name);
- return false;
- }
- }).data("ui-autocomplete")._renderItem = function(ul, item) {
- return $("<li>").append( "<a>" + item.name + "</a>" ).appendTo( ul );
- };
- });
- </script>
- </head>
- <body>
- <div class="ui-widget">
- <input type="hidden" id="hidden_tag" name="hiddentag" value="">
- <label for="tags2">Tags: </label>
- <input type="text" id="tags" />
- </div>
- </body>
- </html>
- <!-- y el autocomplete.php -->
- <?php
- $data=array(array('name'=>'prueba'), array('name'=>'prueba2'));
- echo json_encode($data);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment