'How to check the checkboxes based on the input field value

Like 1,2 or one, two checks the first and second boxes.

I need a solution using Javascript or JQuery

<input type="text" id="select" value="1,2" placeholder="type any thing">

<button id=submit> click </button>

<table>

    <thead>
        <tr>
            <th> </th>
            <th> Name </th>
            <th> ph </th>
            <th> email </th>
            <th> reg no </th>
        </tr>
    </thead>

    <tbody>
        @foreach ($studentlist as $list)
            <tr>
                <!-- THE CHECKBOXES -->
                <td>
                    <div class="checkbox p-0 mr-0">

                        <input type="checkbox" value="{{ $list->studentid }}" name="checkbox[]"
                            id="checkbox-in-{{ $list->studentid }}">

                        <label for="checkbox-in-{{ $list->studentid }}"></label>

                    </div>
                </td>
                <td> {{ $list->studenName }} </td>
                <td> {{ $list->studentphnuumber }} </td>
                <td> {{ $list->email }} </td>
                <td> {{ $list->Regno }} </td>
            </tr>
        @endforeach
    </tbody>

</table>


Sources

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

Source: Stack Overflow

Solution Source