TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Bryan Gomez
NA
21
36.9k
How to get checkbox status and data value [MVC]
Nov 13 2017 4:57 AM
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
Reply
Answers (
2
)
JQuery Chosen Scroll issue
Ajax Call with cache web service url