Some help with backend db operations from datatable results
Some help with backend db operations from datatable results
mihomes
Posts: 150Questions: 19Answers: 0
I have a added a first column of checkboxes with a value=account_id in my datatable. I am using the following to retrieve a list of what checkboxes have been checked by the user in a comma separated string.
[code]
jQuery('.table-toolbar button.delete').live('click', function (e) {
e.preventDefault();
if (confirm("Are you sure to delete this row ?") == false) {
return;
}
alert($("#sample_1 tbody tr input[type=checkbox]:checked").map(
function () {return this.value;}).get().join(",")
);
});
[/code]
I got this code from another example and basically just using it now to make sure it works. An alert box shows with the string of ids that have been checked off when my delete button has been clicked in the thead of the datatable.
What I want to do is :
if (anything selected) {
alert(do you really want to delete?)
send values through ajax to php script to remove rows from db
redraw datatable or remove them (not sure which is better here... probably remove since it wouldn't query the db)
alert(rows were deleted)
else(nothing was selected)
alert that nothing was selected in the table
I know what to do, but the jquery and ajax is new to me as of playing with datatables. Any help would be really appreciated.
[code]
jQuery('.table-toolbar button.delete').live('click', function (e) {
e.preventDefault();
if (confirm("Are you sure to delete this row ?") == false) {
return;
}
alert($("#sample_1 tbody tr input[type=checkbox]:checked").map(
function () {return this.value;}).get().join(",")
);
});
[/code]
I got this code from another example and basically just using it now to make sure it works. An alert box shows with the string of ids that have been checked off when my delete button has been clicked in the thead of the datatable.
What I want to do is :
if (anything selected) {
alert(do you really want to delete?)
send values through ajax to php script to remove rows from db
redraw datatable or remove them (not sure which is better here... probably remove since it wouldn't query the db)
alert(rows were deleted)
else(nothing was selected)
alert that nothing was selected in the table
I know what to do, but the jquery and ajax is new to me as of playing with datatables. Any help would be really appreciated.
This discussion has been closed.