• Как сделать зависимые фильтры с select2?

    jaguar19961
    @jaguar19961 Автор вопроса
    web Developer junior, Laravel, CSS, JS,HTML,JQuery
    Я сделал так но не получается сделать мулти селект...

    view
    <div class="form-group">
                                <label for="">Country</label>
                                <select class="form-control"  name="provinces" id="provinces">
                                    <option value="0" disable="true" selected="true">=== Select Country ===</option>
                                    @foreach ($country as $key => $value)
                                        <option value="{{$value->code}}">{{ $value->name }}</option>
                                    @endforeach
                                </select>
                            </div>
    
                            <div class="form-group">
                                <label for="">University</label>
                                <select class="form-control" name="regencies" id="regencies">
                                    <option value="0" disable="true" selected="true">=== Select University ===</option>
                                </select>
                            </div>
    
                            <div class="form-group">
                                <label for="">Faculty</label>
                                <select class="form-control" name="districts" id="districts">
                                    <option value="0" disable="true" selected="true">=== Select Faculty ===</option>
                                </select>
                            </div>
    
                            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
                            <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    
                            <script type="text/javascript">
                                $('#provinces').on('change', function(e){
                                    console.log(e);
                                    var country = e.target.value;
                                    $.get('/json-regencies?country=' + country,function(data) {
                                        console.log(data);
                                        $('#regencies').empty();
                                        $('#regencies').append('<option value="0" disable="true" selected="true">=== Select University ===</option>');
    
                                        $('#districts').empty();
                                        $('#districts').append('<option value="0" disable="true" selected="true">=== Select Faculty ===</option>');
    
                                        $('#villages').empty();
                                        $('#villages').append('<option value="0" disable="true" selected="true">=== Select Villages ===</option>');
    
                                        $.each(data, function(index, regenciesObj){
                                            $('#regencies').append('<option value="'+ regenciesObj.id +'">'+ regenciesObj.name +'</option>');
                                        })
                                    });
                                });
    
                                $('#regencies').on('change', function(e){
                                    console.log(e);
                                    var id = e.target.value;
                                    $.get('/json-districts?id=' + id,function(data) {
                                        console.log(data);
                                        $('#districts').empty();
                                        $('#districts').append('<option value="0" disable="true" selected="true">=== Select Faculty ===</option>');
    
                                        $.each(data, function(index, districtsObj){
                                            $('#districts').append('<option value="'+ districtsObj.id +'">'+ districtsObj.faculty_id +'</option>');
                                        })
                                    });
                                });
    
                            </script>


    controller
    public function regencies(){
            $provinces_id = Input::get('country');
            $regencies = University::where('country', '=', $provinces_id)->get();
            return response()->json($regencies);
        }
    public function districts(){
        $regencies_id = Input::get('id');
        $districts = UniversityFaculty::where('university_id', '=', $regencies_id)->get();
        return response()->json($districts);
    }
    Ответ написан
    Комментировать
  • Carousels bootstrap как вставить текст в лево по середине?

    jaguar19961
    @jaguar19961 Автор вопроса
    web Developer junior, Laravel, CSS, JS,HTML,JQuery
    чтото не получается сможете помочи?5b689a3123a09518036031.png
    вот так мне нужно зделать
    Ответ написан
    Комментировать