Dependent Dropdowns: Parent-Child

In our QuickAdminPanel generator, we don't have such feature like parent-child dropdowns, for example Country-City relationship where change of Country value refreshes the values of Cities.

However, you can build it yourself quite easily - we have a blog article for you: Laravel Forms: Select Dependent Dropdowns with jQuery and AJAX

In summary, you need to add jQuery code with AJAX call, similar to this:

@section('scripts')
    <script type="text/javascript">
    $("#country").change(function(){
        $.ajax({
            url: "{{ route('admin.cities.get_by_country') }}?country_id=" + $(this).val(),
            method: 'GET',
            success: function(data) {
                $('#city').html(data.html);
            }
        });
    });
    </script>
@endsection

Read more details in the article above.

Last updated