Thameera
1 year ago

pass processed ajax data for options as variable into laravel form input select

Posted 1 year ago by Thameera

$('select[name="unit"]').on('change', function() { var unitID = $(this).val(); if(unitID) { $.ajax({ url: '/stock_receive/add/ajax'+unitID, type: "GET", dataType: "json", success:function(data) {

                        $('select[name="name"]').empty();
                        $.each(data, function(key, value) {
                            $('select[name="name"]').append('<option value="'+ key +'">'+ value +'</option>');
                        });


                    }
                });
            }else{
                $('select[name="name"]').empty();
            }
        });

this is my code to filter the options for input select but here i am using laravel forms how can i change the code to pass data in laravel select input

my laravel input is like {!!Form::select('unit[]', $units, array('class' => 'form-control', 'placeholder' => 'Enter unit','id'=>'unit[]'))!!} here how can i post the data into $unit

Please sign in or create an account to participate in this conversation.