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
ahmed salah
NA
530
147.9k
how to use splice when remove index of course
Sep 16 2016 12:49 PM
i need to remove index of courses so that i need to use splice
how to using splice to return remove courses and added courses
my code as following by jquery and i need to convert to java script by using splice if possible
@model WebCourse.Models.Cusomemp2
@{
Layout =
null
;
}
<!DOCTYPE html>
<html>
<head>
<meta name=
"viewport"
content=
"width=device-width"
/>
<title>Edit</title>
<script src=
"~/scripts/jquery-1.10.2.js"
></script>
<script>
$(
function
() {
var
index = 0;
$(
"#CourseId"
).change(
function
() {
var
id = $(
this
).val();
var
txt = $(
"#CourseId option:selected"
).text();
$(
"#tb"
).append(
"<tr><td><input type = 'hidden' name='empcourses["
+ index +
"].CourseId' value='"
+ id +
"'/></td><td>"
+ txt +
"</td><td><input type='button' value='remove' class='r'</td></tr>"
)
index++;
});
$(
"#tb"
).on(
"click"
,
".r"
,
function
() {
$(
this
).parent().parent().hide();
$(
this
).parent().prev().prev().find(
"input"
).val(
"0"
);
});
$.ajax({
url:
"/Employee/getcoursesbyempid"
,
data:{x:$(
"#hid"
).val()},
success:
function
(res) {
$.each(res,
function
(i, e) {
$(
"#tb"
).append(
"<tr><td><input type = 'hidden' name='empcourses["
+ index +
"].CourseId' value='"
+ e.Id +
"'/></td><td>"
+ e.CourseName +
"</td><td><input type='button' value='remove' class='r'</td></tr>"
)
index++;
});
}
})
});
</script>
</head>
<body>
<div>
@using (Html.BeginForm())
{
<div>
<input type=
"hidden"
value=
"@ViewBag.hid"
id=
"hid"
/>
Name: @Html.TextBoxFor(a => a.Name)
<br />
District:<select id=
"districtlist"
name=
"DistrictId"
></select>
<br />
Courses:@Html.DropDownList(
"CourseId"
)
<br />
<table id=
"tb"
></table>
<input type=
"submit"
value=
"save"
/>
</div>
}
</div>
</body>
</html>
Reply
Answers (
1
)
Need code for black circle bullet point
file upload through ajax request