Assignchklst

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

var assignchklst = {

LeftListBox: $('#chk-listbox-left'),
RightListBox: $('#chk-listbox-right'),
ChecklistArray: [],
UpdateIDs: function () {
$('#values').val('');
$('#chk-listbox-left option').each(function (index) {
console.log($(this).val());
$('#values').val($('#values').val() + $(this).val() + ",");
});
},
SubmitForm: function () {
debugger;
var clientDetail = {
"FirstName": $("#clientFirstName").val(),
"LastName": $("#clientLastName").val(),
"DateofBirth": $("#clientDateofBirth").val(),
"DateofEnrollment": $("#clientEnrollment").val(),
"Email": $("#clientEmail").val(),
"Phoneno": $("#clientPhoneNo").val()
};
$('#chk-listbox-right option').each(function (i, selected) {
assignchklst.ChecklistArray.push($(selected).val());
});
var datamodel = {
"ClientDetail": clientDetail,
"CheckList": assignchklst.ChecklistArray

};
$.ajax({
url: "/ClientDetail/Create",
method: "POST",
data: datamodel,
success: function (data) {
if (data == true) {
window.location.href = "/ClientDetail/Index";
}
assignchklst.ChecklistArray = [];
},
error: function (err) {
}
});
},
SelectItems: function (e) {
var selectedOpts = $('#chk-listbox-left option:selected');
if (selectedOpts.length == 0) {
alert("Nothing to move.");
e.preventDefault();
}
assignchklst.RightListBox.append($(selectedOpts).clone());
$(selectedOpts).remove();
e.preventDefault();
assignchklst.UpdateIDs();
},
RemoveItems: function (e) {
var selectedOpts = $('#chk-listbox-right option:selected');
if (selectedOpts.length == 0) {
alert("Nothing to move.");
e.preventDefault();
}
assignchklst.LeftListBox.append($(selectedOpts).clone());
$(selectedOpts).remove();
e.preventDefault();
assignchklst.UpdateIDs();
}
}

$(function () {
debugger;

$("#btn-add-client").click(function () {

assignchklst.SubmitForm();
});

$('#btnRight').click(function (e) {
assignchklst.SelectItems(e);
});

$('#btnLeft').click(function (e) {
assignchklst.RemoveItems(e);
});

});

SELECT DOCS.ClientChecklist.ChecklistName,
PIF.ClientDetails.FirstName, PIF.ClientDetails.LastName
FROM DOCS.ClientChecklist Right JOIN
PIF.ClientDetails ON
DOCS.ClientChecklist.ClientId = PIF.ClientDetails.ClientId

You might also like