You are on page 1of 1

function selectCourse(x)

{
var courseid = x.value;
alert(courseid);
$.ajax({
url: '/admin/SelectLecture',
type: 'POST',
data: { "courseid": courseid },
success: function (r) {
debugger;
$("#tbl").empty();
$("#chapterlist").empty();
var chapter = []
if (r.length > 0) {
//if (!chapter.includes(i.chapter)) { }
var i = 1;
for (var lec of r) {
if (!chapter.includes(lec.chapter)) {
$("#chapterlist").append(<option>${lec.chapter}</option>);
chapter.push(lec.chapter)
}
$("#tbl").append(`
<tr>
<td>${i}</td>
<td>${lec.title}</td>
<td>${lec.link}</td>
<td>${lec.detail}</td>
<td>${lec.duration1}</td>
</tr>
`)
i++;
}
}

else {
alert('no course present')
}
},

error: function () {
alert('error occured');
}

});
}

You might also like