Binding Drop Down:
<script type="text/javascript">
$(document).ready(function () {
$('#Department').change(function () {
var options = "";
$.ajax({
url: "Bind_Designations",
type: "post",
dataType: "json",
data: { Dept_id: $('#Department').val() },
success: function (data) {
$.each(data, function (index, item) {
options += '<option value=' + item.Value + '>' + item.Text + '</option>'
});
$('#Des_Id').append(options);
},
error: function () {
alert("error");
}
});
});
});
</script>
Binding Drop Down based on Another Drop down Selected Value:
<script type="text/javascript">
$(document).ready(function () {
$('#Des_Id').change(function () {
debugger;
var options = "";
$.ajax({
url: "Bind_Employees",
type: "post",
dataType: "json",
data: { Des_id: $('#Des_Id').val() },
success: function (data) {
debugger;
$.each(data, function (index, item) {
options += '<option value=' + item.Value + '>' + item.Text + '</option>'
});
$('#Emp_Id').append(options);
},
error: function () {
alert("error");
}
});
});
});
</script>
Adding File in Datatable:
<script type="text/javascript">
$(document).ready(function () {
$('#file').change(function () {
var doc_no = $('#Document_Name').val();
var file_name = $('#file').val();
file_name = file_name.substring(12, file_name.length);
var extension = file_name.substr((file_name.lastIndexOf('.') + 1));
$('#Document_Details').append('<tr><td>' + i + '</td><td>' + 123 + '</td><td>' + doc_no + '</td><td>' + file_name + '</td> </tr>');
var i = "";
i = addSerialNumber();
debugger;
});
});
</script>