lundi 16 novembre 2020

How to pass data id to modal?

i need to pass the dropdown id value once been selected. The id must be pass to modal.

This is my code for view :

<div class="panel panel-default">
    <div class="panel-heading">
        <h4></h4>
    </div>
    <div class="panel-body">
        <div class="form-horizontal">
            <label class="col-lg-2 control-label">{!! msg('lbl_education_level') !!}</label>
            <div class="col-lg-4">
                {!! Form::dropdown('education_level_id', $edulevelselection, '', 'class="select2-form edulevel"') !!}
            </div>
            <span>
                    {!! Form::buttonAdd('','#',[
                    'data-toggle' => 'modal',
                    'id' => 'education',
                    'data-title' => msg('lbl_new_academic_qualification'),
                    'data-target' => '#modal_global_form',
                    'data-url' => route('academic_qualification.create', [ 'id' => $staff_id] ),
                    'data-action' => route('academic_qualification.store'),
                    'data-size' => 'modal-lg',
                    'data-param' => '{ }'
                    ]) !!}
                </span>
        </div>
    </div>
</div>
@push('scripts')
<script type="text/javascript">

$('#education_level_id').change(function(e){
    var edulevelid = $('#education_level_id').val();
    console.log(edulevelid);
    $('#education').attr('data-param','{"education_level_id":'+edulevelid+'}');
})

</script>
@endpush

But the value i want is not show up, i do the dump() at the controller. it just show my id only. This is the dump i make on the controller:

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire