-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrud.js
More file actions
72 lines (62 loc) · 2.01 KB
/
crud.js
File metadata and controls
72 lines (62 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
File Name : crud.php
File Path : C:\xampp\htdocs\phpCRUD
Description : JS page to handle Edit and Delete functions
Created date : 04/02/2019
Author : Mukesh
*/
var crud = (function() {
$( "table tbody" ).on( "click", "#b_Update", function(){
var id = $(this).closest('tr').find('td:eq(0)').text();
var firstname = $(this).closest('tr').find('td:eq(1)').text();
var lastname = $(this).closest('tr').find('td:eq(2)').text();
var email = $(this).closest('tr').find('td:eq(3)').text();
$("#updatefirstname").val(firstname);
$("#updatelastname").val(lastname);
$("#updateemail").val(email);
$("#updateModal").modal();
$("#save_btn").click(function(){
$.ajax({
type: "POST",
url: "update-user.php",
data:{
id,
updatefirstname : $("#updatefirstname").val(),
updatelastname : $("#updatelastname").val(),
updateemail : $("#updateemail").val()
},
success: function (updatemsg){
$("#updatemsg").html(updatemsg);
//$("#updateModal").modal('hide');
}
});
});
});
$( "table tbody" ).on( "click", "#b_Del", function(){
var del_id = $(this).closest('tr').find('td:eq(0)').text();
var $ele = $(this).parent().parent();
$.ajax({
type: "POST",
url: "delete-user.php",
data: {
'del_id':del_id
},
success: function(data)
{
if (data=="YES")
{
$ele.fadeOut().remove();
}
else
{
alert("can't delete the row");
}
}
});
});
$("#close_btn").on("click", function(){
location.reload();
});
return{
}
})();