Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
How to get checkbox status and data value [MVC]
Bryan Gomez
Nov 13 2017 4:57 AM
126
Reply
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
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
JQuery Chosen Scroll issue
Ajax Call with cache web service url