Monday, March 20, 2017

Unable to get updated Id in bootstrap modal (laravel 5.3)

I am working on laravel 5.3 i have a feature for add marks i am getting a list of students using foreach loop and against avery student i have a button to add marks it looks as View of retrived students

I want to send Student Id showing in image to the controller When i click on add marks button its gives a modal where always id remains one even i clicked on 2nd row my code is as

    @foreach($students as $index => $student)
                        <tbody>
                            <tr>
                                <td>  </td>
                                <td>  </td>
                                <td> </td>
                                <td class='customerIDCell'> </td>
                                <td><a href="#marks-student" data-toggle="modal">
                                <button id="sample_editable_1_new" class="btn sbold green">
                                    Add Marks <i class="fa fa-plus"></i>
                                </button></a></td>
                            </tr>
                        </tbody>
                        <div id="marks-student" class="modal" role="dialog" aria-hidden="true">
    <div class="modal-dialog" style="width: 500px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Student Marks</h4>
            </div>
            <div class="modal-body">
            <form action="" method="POST" id="ip-suppression-frm" class="form-horizontal">
            <input type="hidden" name="_token" value="">
            <input type="hidden" name="student_id" value="">
                <div class="form-group">
                        <label class="control-label col-md-3">Marks
                            <span class="required"> * </span>
                        </label>
                        <div class="col-md-8">
                            <div class="input-icon right">
                                <i class="fa"></i>
                                <div class="input-icon right">
                                <i class="fa"></i>
                                <input type="text" name="marks" class="form-control" value="" />
                            </div>
                            </div>
                        </div>
                    </div>
                <div class="form-actions">
                    <div class="row">
                        <div class="col-md-offset-5 col-md-9">
                            <button type="submit" class="btn green">Submit</button>
                            <button type="reset" class="btn grey-salsa btn-outline">Reset</button>
                        </div>
                    </div>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>
@endforeach

When i submit modal i always get 1 there even i submit for user 2 .. In above code i am sending student id as hidden variable.

this line of code is as also written in above code

<input type="hidden" name="student_id" value="">

Please help where i am going wrong and how to get exact id of student

Thanks in advance



via recovery men

Advertisement