Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>jQuery UI Autocomplete - Default functionality</title>
- <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
- <?php App::import('Controller','Products');App::import('Controller','Manufacturers');
- <link rel="stylesheet" href="/resources/demos/style.css">
- <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
- <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
- <script>
- $( function() {
- var availableTags = [
- "ActionScript",
- "AppleScript",
- "Asp",
- "BASIC",
- "C",
- "C++",
- "Clojure",
- "COBOL",
- "ColdFusion",
- "Erlang",
- "Fortran",
- "Groovy",
- "Haskell",
- "Java",
- "JavaScript",
- "Lisp",
- "Perl",
- "PHP",
- "Python",
- "Ruby",
- "Scala",
- "Scheme"
- ];
- $( "#tags" ).autocomplete({
- source: availableTags
- });
- } );
- </script>
- </head>
- <body>
- <div class="ui-widget">
- <label for="tags">Tags: </label>
- <input id="tags">
- </div>
- $query = $this->params['url']['term'];
- $return_arr = array();
- $products = $this->Product->find('all', array('fields' => array('DISTINCT (Product.product_name) AS product_name'),'conditions' => array('Product.product_name LIKE' => $query.'%')));
- foreach($products as $product) {
- $return_arr[] = $product['Product']['product_name'];
- }
- echo json_encode($return_arr);
- }?>
- public function suggestion() {
- $this->autoRender = false;
- $query = $this->params['url']['term'];
- $return_arr = array();
- $manufacturers = $this->Manufacturer->find('all', array('fields' => array('Manufacturer.manufacturer'),'conditions' => array('Manufacturer.manufacturer LIKE' => $query.'%')));
- foreach($manufacturers as $manufacturer) {
- $return_arr[] = $manufacturer['Manufacturer']['manufacturer'];
- }
- echo json_encode($return_arr);
- }?>
Add Comment
Please, Sign In to add comment