'How to get multiple value from checkbox Table after selecting it and remove the value if check box is deselected using jquery

blade.file

<table class="table table-borderless">
    <thead>
        <tr>
            <th> </th>
            <th> Name </th>
            <th> ph </th>
            <th> email </th>
            <th> reg no </th>
        </tr>
    </thead>

    @foreach ($studentlist as $list)
        <tr>
            <td>

                <div class="checkbox p-0 mr-0">

                    <input type="checkbox" value="{{ $taxList->studentid }}" name="checkbox[]"
                        id="checkbox-in-{{ $list->studentid }}" class="multi-select-tax">

                    <label for="checkbox-in-{{ $taxList->studentid }}" class="cr PRAV01-checkbox"></label>

                </div>

            </td>
            <td> {{ $taxList->studenName }} </td>
            <td> {{ $taxList->studentphnuumber }} </td>
            <td> {{ $taxList->email }} </td>
            <td> {{ $taxList->Regno }} </td>
        </tr>
    @endforeach
 </tbody>
</table>
    <label>Students</label>
    <input type="text" class="form-control" multiple="multiple" id='student-id' name="student">
    <button class="btn btn-primary ">Add</button>

There are 5 five students.

If I select 2nd and 3rd student with checkbox select (multi select).the selected student id should store in input field(id=student-id) as 2,3

If I unselect means value should removed.

How I can do this method with help of Jquery or JavaScript.

I tried 2 method but I didn't get ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source