Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.js"></script>
- <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css">
- <script>
- $(document).ready(() => {
- let data = [{id: 1, label: "Иван Иванов", email: "[email protected]", phone: "12345344", title: "Мениджър"},
- {id: 2, label: "Мария Петрова", email: "[email protected]", phone: "368938736", title: "Програмист"},
- {id: 3, label: "Стефан Колев", email: "[email protected]", phone: "866893", title: "Финансов директор"},
- {id: 4, label: "Петя Илиева", email: "[email protected]", phone: "10237129", title: "Бодигард"},
- {id: 5, label: "Деница Филева", email: "[email protected]", phone: "0739483", title: "Офис сътрудник"}];
- let cities = ['Varna', 'Sofia', 'Plovdiv'];
- $('#search').autocomplete({
- source: data,
- minLength: 0,
- select: (event, ui) => {
- $('.card-title').html(ui.item.email);
- $('body').append('<input type="text" style="display:none" value="' + ui.item.id + '">');
- }
- });
- // select: (event, ui) => {
- // $('.card-title').html(ui.item.email);
- // $('#search').val( ui.item.label + ' (' + ui.item.email + '), ' + ui.item.title);
- // return false;
- // }
- // }).autocomplete('instance')._renderItem = (ul, item) => {
- // return $('<li>').append('<div>' + item.label + ' (' + item.email + '), ' + item.title + '</div>').appendTo(ul);
- // };
- });
- </script>
- </head>
- <body>
- <div class="container my-5">
- <div class="row justify-content-center">
- <div class="col-6">
- <input type="text" placeholder='Search' id="search" class='form-control d-inline-block'>
- </div>
- </div>
- <div class="row justify-content-center my-3">
- <div class="col-4">
- <div class="card p-3 text-center">
- <div class="card-title">
- </div>
- </div>
- </div>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement