Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="utf8">
  5.     <title>Paper Heros Comics Inventory Locator</title>
  6.     <link rel="stylesheet" href="/PH_Inventory/jquery-ui-1.11.2.custom/jquery-ui.css">
  7.     <script src="/PH_Inventory/jquery-1.11.2.min.js"></script>
  8.     <script src="/PH_Inventory/jquery-ui-1.11.2.custom/jquery-ui.js"></script>
  9.     <style>
  10.         #cards { width: 25em; }
  11.     </style>
  12.    
  13. </head>
  14. <body>
  15.     <div class="ui-widget">
  16.     <label for="cards">Cards: </label>
  17.     <input id="cards">
  18. </div>
  19. <script>
  20.         $(function() {
  21.             $( "#cards" ).autocomplete({
  22.                 delay: 500,
  23.                 minLength: 3,
  24.                 source: function( request, response ){
  25.                     $.getJSON("http://yugiohprices.com/api/card_data/",{
  26.                          q: request.term,
  27.                          page_limit: 10
  28.                     }, function(data) {
  29.                         var cardArray = data.error ? [] : $.map(data.card_data, function(c){
  30.                             return {
  31.                                 value: c.name,
  32.                                 label: c.name
  33.                             };
  34.                         });
  35.                         response(cardArray);
  36.                     });
  37.                 },
  38.                 focus: function(event, ui) {
  39.                     // prevent autocomplete from updating the textbox
  40.                     event.preventDefault();
  41.                 },
  42.                 select: function(event, ui) {
  43.                     // prevent autocomplete from updating the textbox
  44.                     event.preventDefault();
  45.                     // navigate to the selected item's url
  46.                     window.open(ui.item.url);
  47.                 }
  48.             });
  49.         });
  50. </script>
  51.  
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement