'Is there a way to make an autocomplete in 2 fields where the first change the possible values in the second? (JS, SQL and PHP)

I made an autocomplete using jquery where the first field is required in a SQL (SSMS) table and are different trucks manufacturers, I need the second field to be just that manufacturers' models but can't figure out how i could do that. :( Here's part of my HTML:

<div style="width:500px;">
    <label>Marca<input type="text" id="marca" name="marca" placeholder="Write the truck manufacturer"
        required /></label>
</div>
<div style="width:500px;">
    <label>Modelo<input type="text" id="modelo" name="modelo" placeholder="Write the truck model"
    required /></label>
</div>

JavaScript:

<script>
$.getJSON("search.php", function(data){
    var item_callback = [];
    $(data).each(function(key,value){
        item_callback.push(value.CAM_FABRN);
    })
    $("#marca").autocomplete({
        source: item_callback
    });
});
</script>

Part of the php:

<?php
session_start();
require_once "connection.php";
$fabricantes = $conn->prepare("SELECT DISTINCT CAM_FABRN 
                                FROM CAM010 
                                WHERE CAM_DTE >='2018'");
$fabricantes->execute();
echo json_encode($fabricantes->fetchAll(PDO::FETCH_ASSOC));
?>

connection.php is:

<?php 
$conn = new PDO( "sqlsrv:Server=(local) ; Database = Portal_Registro ", "", "", array(PDO::SQLSRV_ATTR_DIRECT_QUERY => true));
?>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source