How to get the checkbox status and data value from my table in HTML? I want to get the @myJob.so_no.
Here's my view:
- <table class="table table-striped table-hover table-condensed" id="myJobTable">
- <thead class="thead-dark">
- <tr>
- <th scope="col">#</th>
- <th scope="col"></th>
- <th scope="col">Date</th>
- <th scope="col">SO No</th>
- <th scope="col">Serial</th>
- <th scope="col">Status</th>
- <th scope="col">Technician</th>
- </tr>
- </thead>
- @foreach (MyJobAllocation myJob in Model.MyJob)
- {
- <tr>
- <td>@myJob.row</td>
- <td>
- <input type="checkbox" id="chk" />
-
- </td>
- <td>@myJob.date</td>
- <td>@myJob.so_no</td>
- <td>@myJob.serial</td>
- <td>@myJob.status</td>
- <td>@myJob.technician</td>
- </tr>
- }
- </table>
And for my script:
I'm trying to print a simple alert if my function is working. But it doesn't.
- function asign_to() {
- var table = document.getElementById("myJobTable");
- var value_check = "";
- for (var i = 0; i < table.rows.length; i++) {
- if ($('#chk')[i].is(':checked')) {
- alert('You clicked me!');
- }
- }
- }
Got this error:
- TypeError: $(...)[i].is is not a function