Search
 
SCRIPT & CODE EXAMPLE
 

PHP

bootstrap autocomplete example laravel

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>Laravel Typeahead JS Autocomplete Search</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" />
    <style>
        .container {
            max-width: 600px;
        }
    </style>
</head>
<body>
    <div class="container mt-5">
        <div classs="form-group">
            <input type="text" id="search" name="search" placeholder="Search" class="form-control" />
        </div>
    </div>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.1/bootstrap3-typeahead.min.js">
    </script>
    <script type="text/javascript">
        var route = "{{ url('autocomplete-search') }}";
        $('#search').typeahead({
            source: function (query, process) {
                return $.get(route, {
                    query: query
                }, function (data) {
                    return process(data);
                });
            }
        });
    </script>
</body>
</html>
Comment

bootstrap autocomplete example laravel

<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use AppModelsUser;
class TypeaheadController extends Controller
{
    public function index()
    {
        return view('welcome');
    }
 
    public function autocompleteSearch(Request $request)
    {
          $query = $request->get('query');
          $filterResult = User::where('name', 'LIKE', '%'. $query. '%')->get();
          return response()->json($filterResult);
    } 
}
Comment

PREVIOUS NEXT
Code Example
Php :: close route in laravel 
Php :: php timezone paris 
Php :: limit wordpress search to title 
Php :: php while select query 
Php :: laravel collection every 
Php :: check if config exist laravel 
Php :: php pdo delete 
Php :: wordpress change email new user template 
Php :: date in russian php 
Php :: laravel 7 upload file s3 
Php :: woocommerce_product_is_on_sale filter 
Php :: get time ISO 8601 wordpress 
Php :: send mail infinityfree phpmailer 
Php :: octobercms mail view 
Php :: how to add files in child theme in theme editor 
Php :: laravel validation on update 
Php :: increase file upload size limit 
Php :: convertir date php en français 
Php :: How to get a list of registered route paths in Laravel? 
Php :: laravel collection nth method 
Php :: split date range into weeks php 
Php :: php unix socket client 
Php :: Symmetric encryption in PHP 
Php :: difference between array_merge and + 
Php :: find the next 7 date data in laravel eloquent 
Php :: php function use 
Php :: mysql gone away error in php 
Php :: Laravel whereHas with count 
Php :: laravel multiple images upload 
Php :: adding two numbers in php 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =